开发者

.conf not found via php

开发者 https://www.devze.com 2023-02-16 03:39 出处:网络
I am trying to read a a .conf file under /var/www/myDir on linux. This is the code $confFile = \"vhost.conf\";

I am trying to read a a .conf file under /var/www/myDir on linux.

This is the code

$confFile = "vhost.conf";
if (file_exists($confFile)) {
    echo "The file $filename exists";
} else {
    echo "Th开发者_高级运维e file $filename does not exist";
}

It says file not found. Any ideas why>

Thanks Jean


Give the full path

$confFile = "/var/www/myDir/vhost.conf";


is your script executed in the same Path? otherwise try using the full path

if (file_exists('/var/www/myDir'. $confFile)) {

...


Try using absolute paths, like this:

$confFile = $_SERVER['DOCUMENT_ROOT'] . "/vhost.conf";
if (file_exists($confFile)) {
    echo "The file $filename exists";
} else {
    echo "The file $filename does not exist";
}

Or maybe this:

$confFile = "/var/www/myDir/vhost.conf";
if (file_exists($confFile)) {
    echo "The file $filename exists";
} else {
    echo "The file $filename does not exist";
}
0

精彩评论

暂无评论...
验证码 换一张
取 消