提示找不到文件
PHP入门篇-【3-13】PHP第一种特殊类型-资源
【尝试1】
我在本地网站根目录放了一个f.txt文件,
任务代码如下
$file_handle = fopen("http://localhost/f.txt","r");
报错找不到文件,提示信息:
Fatal error: Uncaught exception 'Yaf_Exception_LoadFailed_Controller' with message 'Failed opening controller script /webroot/app/controllers/F.txt.php: No such file or directory' in /webroot/index.php:12
Stack trace:
#0 /webroot/index.php(12): Yaf_Application->run()
#1 {main}
thrown in /webroot/index.php on line 12
——————————————————————————————————————
【尝试2】
直接用本地路径取,代码段
$file_handle = fopen("D:/PHP_coding/f.txt","r");
还是报错,报错信息如下
Warning: fopen(D:/PHP_coding/f.txt): failed to open stream: No such file or directory in /54/754/InX3/index.php on line 3
Warning: fclose() expects parameter 1 to be resource, boolean given in /54/754/InX3/index.php on line 12
——————————————————————————————————————
【尝试3】
我的apache是修改过端口的,尝试用代码段
$file_handle = fopen("localhost:8080/f.txt","r");
还是报错,报错信息如下
Warning: fopen(localhost:8080/f.txt): failed to open stream: No such file or directory in /54/754/InX3/index.php on line 3
Warning: fclose() expects parameter 1 to be resource, boolean given in /54/754/InX3/index.php on line 12
请各位分析一下我应该怎么修改才能正常显示文件内容= =