Call div when specific link

0

I have a file with dynamic content in PHP. I have a div that I want to be displayed whenever the site link is / who-is.

How to do this in PHP?

    
asked by anonymous 11.06.2018 / 16:42

2 answers

1

You can use preg_match to check if the URL ends with the string /quem-somos or /quem-somos/ :

<?php
$url_atual = $_SERVER[REQUEST_URI]; // URL da página atual
$match = preg_match('\/quem-somos[\/]?$/', $url_atual, $matches); // verifica a string na URL
if($matches){ // se casou, carrega a div
?>
<div></div>
<?php
} // fecha o if
?>

Test regex in RegExr

    
11.06.2018 / 18:17
0

So I understand and only you use the GET mode.

$url=$_GET['mostrar'];
if($url="quem-somos"){
   echo "<div id='IDdaDiv'> </div>";   
}

So if the url is site.com/index.php?show=we are it will show the div case if n n goes. you can use friendly URL for n to show "index.php? show=" and yes only "site.com/we--"

    
11.06.2018 / 18:15