php无法打开流

时间:2014-04-21 05:07:07

标签: php stream

我有一个错误,我认为它与public_html文件的目录有关,但我不确定。

错误:

Warning: require(__DIR__/protected/bootstrap/autoload.php) [function.require]: failed to open stream: No such file or directory in /home4/nameguy/public_html/index.php on line 21

Warning: require(__DIR__/protected/bootstrap/autoload.php) [function.require]: failed to open stream: No such file or directory in /home4/nameguy/public_html/index.php on line 21

Fatal error: require() [function.require]: Failed opening required '__DIR__/protected/bootstrap/autoload.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home4/nameguy/public_html/index.php on line 21

Index.php代码:

<?php
require __DIR__.'/protected/bootstrap/autoload.php';

$app = require_once __DIR__.'/protected/bootstrap/start.php';

$app->run();

$app->shutdown();

1 个答案:

答案 0 :(得分:2)

__DIR__仅在PHP 5.3之后定义,因此您可能拥有旧版本。您可以改为使用__FILE__

<?php
require dirname(__FILE__).'/protected/bootstrap/autoload.php';

$app = require_once dirname(__FILE__).'/protected/bootstrap/start.php';