开发者

.conf not found via php

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜