phpdetect

How to detect what page user is on with php


I need to create some if else statements depending on what page user is, I tried looking for this in php manual, but didn't find anything useful.

Basically what I want is a syntax for something like:

if (user is on a page index.php)

 $message = $_GET["title"];
 if $message = "hello";
 $say = "Hello";

etc ....

Can anyone show how this can be done?


Solution

  • Try looking at _SERVER[REQUEST_URI], _SERVER[SCRIPT_NAME], _SERVER[SCRIPT_FILENAME], _SERVER[PHP_SELF], and possibly others.