I am trying to display something on web pages that show this in the url: "sub" for example: ...com/videos/category/1/sub536. It was suggested I try this code:

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

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

Well, when I put that code on the page, as-is, I see "page isn't working.

Any guidance/suggestion is appreciated

Hi Chris,

Sorry, I'm having a difficult time understanding exactly what you are trying to display.

If a url is example.com/videos/category/1/sub536 then print sub?

If it's /videos/category/1/sub__ then ... what??

Does every url include the word sub? I'm confused what heuristic you want to check for and print?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.