PHP 8.1.2 realpath returning false



我目前正在将我的PHP网站从7.4升级到8.1.2,但我的"realpath"有问题。无论我放在哪个目录中,变量'$install_folder'都显示为false。这很奇怪,因为我在我的PHP 7.4网站上测试了这一点,并且代码正常工作。

$install_folder = realpath(__DIR__ . '/../../../');

我试图通过以下方式解决问题:

$dir = __DIR__; 
$install_folder = realpath($dir . '/../../../');

如有任何建议,我们将不胜感激!

您的系统上是否安装了php-cli解释器?在基于Debian/Ubuuntu的系统上,这是phpX-cli包。

如果安装了cli包,我希望看到一个测试脚本的输出,它可能会对事情有所了解。

#/path/to/php8
$dir = __DIR__;
echo $dir;
$install_folder = realpath($dir);
echo $install_folder;

以常规用户身份运行此脚本,然后以运行网站的用户身份运行。

最新更新