访问 Windows PHP fopen 流中的特殊命名文件夹
http://en.wikipedia.org/wiki/Special_Folders
我在访问时遇到问题php 中 fopen 流中的特殊文件夹。
示例
$fp = fopen("%USERPROFILE%/Desktop/text.txt", 'wb');
fwrite($fp, $data);
fclose($fp);
我尝试使用 sysinternals 进程监视器运行来尝试查看实际发生的情况,它看起来像这样。
C:/xampp/htdocs/test/%USERPROFILE%/Desktop/text.txt PATH NOT FOUND
显然有两件事出了问题,PHP 将路径视为相对路径,并且不评估特殊文件夹。
http://en.wikipedia.org/wiki/Special_Folders
I am having a problem with accessing a special folder in a fopen stream in php.
Example
$fp = fopen("%USERPROFILE%/Desktop/text.txt", 'wb');
fwrite($fp, $data);
fclose($fp);
I try this with sysinternals process monitor running to try and see what is actually happening and it looks something like this.
C:/xampp/htdocs/test/%USERPROFILE%/Desktop/text.txt PATH NOT FOUND
Well apparently two thing are going wrong, PHP is treating the path as a relative path and the special folder is not being evaluated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅
$_ENV
手册以及getenv()
。正如 Johannes Rössel 所说,这仅在有限的情况下有效。您可以改用这个内部函数:
See
$_ENV
on the manual and alsogetenv()
.As Johannes Rössel said, this will only work in limited circumstances. You can use this internal function instead: