是否有可能在PHP中获得<a href>?

I'm actually trying to find a way to get the href in my website url because i want to change the typo color regarding this href, but i can't find how to do it.

For example, if i have the URL http://localhost/website/?date=2019#Presse

I would like to get the "Presse"

Here is my code :

<div class=" col-sm-3 col-12">
    <div class = "row">

        <div class="col-12"><a  class = "<?php //php code to get the href ?>" href="#Distinctions">Distinctions</a></div>

        <div class="col-12"> <a class = "<?php //php code to get the href ?>" href="#Presse">Presse</a></div>

        <div class="col-12"> <a class = "<?php //php code to get the href ?>" href="#Expositions">Expositions</a></div>

        <div class="col-12"><a class = "<?php //php code to get the href ?>" href="#Conférences">Conférences</a><br/><br/></div>

Is it possible to get this in PHP ?

Thanks

try this,hope it helps

echo $str=explode("#","http://localhost/website/?date=2019#Presse")[1];
//output Presse

You can use this

<?php
$url = "Thttp://localhost/website/?date=2019#Presse";
$presse = parse_url($url,PHP_URL_FRAGMENT);

echo $presse;
?>

I have used parse_url. This function parses a URL and returns an associative array containing any of the various components of the URL that are present. The values of the array elements are not URL decoded.
PHP_URL_FRAGMENT to retrieve just a specific URL component. For more info, you can visit manual

Here is the live demo

You should get url parameter then explode to split date and string then use your string as class Try this code

class="<?php if (isset($_GET['date'])) {  $string=explode('#',$_GET['date']); echo $string[1]; } else { echo 'red'; }" ?>

<a href="<?php //php code to get the href ?>#Distinctions" class="classname">Title</a>

</div>

Thank you for all your answers. I'm sorry, but i think i have not been clear in my question : i have to get the full url first because the #id can change. It can end by #Presse or by #Distinctions for example (or i just did not understand your answers, thats possible too :) )

But i don't know why, i had an "illumination", and i did it in JS (it's working) :

  function changeBold(name)
{
    document.getElementById(name).className = "navigationB";
    if(name != 'Distinctions')   document.getElementById('Distinctions').className = "navigation";
    if(name != 'Presse')   document.getElementById('Presse').className = "navigation";
    if(name != 'Expositions')   document.getElementById('Expositions').className = "navigation";
    if(name != 'Conférences')   document.getElementById('Conférences').className = "navigation";
}