First of all, I dont know too much of this code, and I know it is very poor, forgive me.
In my website I had a deprecated code “ereg” that now I am trying to resolve with preg_match but I have no idea of this new PHP code.
function Menu($sitio) {
$url = 'http://www.'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
if(ereg($sitio, $url)) {echo 'class="totalactive"';}
}
As you can see, if I have a list with for example:
<li <?php Menu (/contact) ?>>
if you are in http://www.yourwebsite.com/contact the code works. (but i think there are better ways to do this, because i have problems with the principal page, and any other website that is not on this list.)
I think this code is too bad, and know with php5.3 or more is even more useless.
Is there a new way to do this with Preg_match detecting the site and setting by default one of them?. Or a totally new and better way to fix this with php5.3?
Just replace your
eregcall by this.To only match the specified url you have to add a start and end sign to that regular expression like this: