One-liners vs. coding stories

Disclaimer: another useless technical article, for programmers only!

I was not very satisfied with this line of PHP code:

<?php
if (trim(dirname(parse_url($_SERVER['PHP_SELF'], PHP_URL_PATH)), '/') === $requestedpage) 
  { $requestedpage = ""; } 
?>

Happy_the_Exceed, on the IRC channel #PHP, turned it into a nice story, following his motto

Your PHP code should literally be like a story

Here it is:

<?php
# once upon a time, there were url chunks, derived from myself and the url path!!
$url_chunks = parse_url($_SERVER['PHP_SELF'], PHP_URL_PATH);

# Which were used to get the parent's directory
$parent_directory = dirname($url_chunks);

# Ah, there may be a /, let's give it a jolly good trim!
$somePage = trim($parent_directory, '/');

# Then we attempt to figure out in some odd ball way whether this is a home page or not o_o
if ($somePage == $requestedpage) {
    $requestedpage = '';
}

If you haven't understood anything about the previous discussion (or even if you have), here is something relaxing now: