Here is my code – not sure why it isn’t working:
<?php
$urlroot = $_SERVER['HTTP_HOST'];
$urllink = "http://" . $urlroot;
$DirPath = getcwd() . "\n";
$InnermostDir = basename(rtrim($DirPath, '/'));
if ($InnermostDir == $urlroot) {
$InnermostDir = 'home';
echo $InnermostDir;
};
?>
If I do an echo on $InnermostDir and $urlroot, they both show the domain example.com. So not sure why this won’t return true?
$DirPathcontains a\nat the end, which is not removed, therefore the strings won’t be equal.rtrim($DirPath, '/')will only remove/characters from the end, not the\n. If you want it to remove the\nas well, you need to usertrim($DirPath, "/\n"), or simply don’t add that\nwhen setting$DirPath.