PHP将文件作为目录?

| 我已经删除了php文件扩展名,因此我的文件没有.php,但是现在我的一些PHP代码开始认为它是目录。 看这个:
<?php
$currentDir = dirname($_SERVER[\'SCRIPT_NAME\']);
if ($currentDir == \'/website/products\') {
    echo \'<li class=\"current\"><a href=\"http://localhost/website/products\">Products</a></li>\';
}
else {
    echo \'<li><a href=\"http://localhost/website/products\">Products</a></li>\';
}
然后,如果我在产品文件夹中有一个名为example.php的文件,那么如果我在地址字段中键入example.php,它将进入第一个类为class = \“ current \”的文件。 但是如果我在没有PHP扩展名的地址字段中输入example,我会进入else并且不会得到
class=\"current\"
:( :( :( 你能帮我吗???     
已邀请:
        一种选择是再次添加这些扩展名,仅对Apache使用mod_rewrite
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\\.php -f
RewriteRule ^(.*)$ $1.php
    

要回复问题请先登录注册