Help with referencing url in code

I am trying to display something on web pages that show this in the url: “sub__” for example: …com/videos/category/1/sub__536. It was suggested that I try some code like this:

$page = basename($_SERVER['PHP_SELF']); 
if ($page=="content.php") {
echo Hello World; 
} elseif ($page=="content.php") {
Some Other code... 
}

but I don’t know where to place the url in that code to make it purposeful.
And I’m not sure that I need if/else, just would like if: /videos/category/1/sub__ then show echo

The code above just gives a 404 error.

Any help/suggestions with display something on web pages that show this in the url: “sub__” is appreciated

The error is ds because there are no quotes around Hello World

Try the following:

echo '<br>', 
  $_SERVER['PHP_SELF'];
echo '<br><br>',   
$page = basename($_SERVER['PHP_SELF']); 
if ($page=="content.php") {
  echo '<br> Hello World'; 
} elseif ($page=="content.php") {
  echo '<br> Some Other code... ';
} else {
  echo '<br> Something ELSE code... ';
}

Isn’t a 404 (“Page not found”) error a strange one to get? I’d have expected a parse error, perhaps resulting in a 500.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.