PHP - Check which page is running

Asked

Viewed 464 times

0

I have a config.php file, all the other files on the site include it.

I’m having trouble checking which page config.php is currently running.

Only example I found was using is_page but failed

if(is_page('about')){
    echo "estou na pagina about";
}else{
    echo "não estou na pagina about";
}

Thank you in advance!

  • Wordpress ?

  • That’s right, that function is_page has face to be Wordpress. Without it, you can utilize the $_SERVER["REQUEST_URI"], that has the URI accessed.

  • Worked right buddy

  • You can put a variable with the page name on all pages, before include config.php, for example: on the about page $pagina="about"; on the home page $pagina="Home"; etc... In config.php puts echo "estou na pagina ". $pagina;

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.