【发布时间】:2011-02-17 12:35:04
【问题描述】:
问题:我们的代码库很大,无法正常工作。我们通过排除过程发现以下几行是导致问题的原因。
我们在两台机器上有一个相同的小脚本(访问密钥已修改)。
$url = "http://images.shrinktheweb.com/xino.php?stwsize=xlg&stwaccesskeyid=82322b94fs1c912&stwu=bfbf5&stwinside=1&stwurl=http%3A%2F%2Fwww.digitalartistshandbook.org%2Fnode%2F35";
$lines = file($url);
print implode("", $lines);
机器 1:
- 此脚本运行良好并打印出预期的响应。
机器 2(问题):
- 此脚本不起作用,并且不会向终端打印任何内容。它在 php.log 或终端上没有错误完成。
现在,使用另一个脚本:
$url = "http://images.shrinktheweb.com/xino.php?stwsize=xlg&stwaccesskeyid=82322b94fs1c912&stwu=bfbf5&stwinside=1&stwurl=";
$lines = file($url);
print implode("", $lines);
我们遇到过 URL 使用 stwurl 集的奇怪情况,但并不可靠 我们回去尝试了一些已成功检索缩略图但无法正常工作的方法。
错误和fopen设置:
;;;;;;;;;;;;;;;;;; ; fopen 包装器; ;;;;;;;;;;;;;;;;;; ;是否允许将 URL(如 http:// 或 ftp://)视为文件。 allow_url_fopen = 打开 ;是否允许 include/require 将 URL(如 http:// 或 ftp://)作为文件打开。 allow_url_include = 关闭这是一台两台机器。错误配置:
error_reporting = E_ALL
并且都成功登录到 /tmp/php.log
【问题讨论】:
-
基本调试:这段代码的输出是什么——
echo 'here 1'; $lines = file($url); echo 'here 2'; implode("", $lines); echo 'here 3'; -
你好 Dan,所有的 echo 都打印成功了。所以,我假设文件()中的 $lines 是空的。感谢您的回复 - 还有其他建议吗?
-
var_dump($lines)输出什么? -
如果放在
$lines = file($url)之前,var_dump(error_reporting())会输出什么?