当前位置:Gxlcms > PHP教程 > !在Yii中使用fopen找不到路径

!在Yii中使用fopen找不到路径

时间:2021-07-01 10:21:17 帮助过:10人阅读

求助!在Yii中使用fopen找不到路径
我的代码写在view中php文件,
具体代码:
$file_url=Yii::app()->request->baseUrl."/file/";
$file_name=$file_url.'test.txt';
if($file=fopen($file_name, "w")){
fwrite($file, '这是测试内容1');
fclose($file);
}

显示错误:
fopen(/yiitest/file/test.txt) [function.fopen]: failed to open stream: No such file or directory

------解决方案--------------------
baseUrl 是网站的路径... fopen打开的是文件系统的路径的,不能混为一谈的.
------解决方案--------------------
路径加上域名就可以了
------解决方案--------------------
探讨

baseUrl 是网站的路径... fopen打开的是文件系统的路径的,不能混为一谈的.

人气教程排行