从书中使用命令行运行PHP脚本
问题描述:
我想运行这个PHP脚本,我从书中的webbots,蜘蛛和屏幕抓取。从书中使用命令行运行PHP脚本
$target = "http://www.WebbotsSpidersScreenScrapers.com/hello_world.html";
$file_handle = fopen($target, "r");
# Fetch the file
while(!feof($file_handle))
echo fgets($file_handle, 4096);
fclose($file_handle);
我正在使用php first.php命令,它所做的就是将文件连接回给我。
答
你的完整剧本,应该是这样的
<?php //<- opening tag for PHP
$target = "http://www.WebbotsSpidersScreenScrapers.com/hello_world.html";
$file_handle = fopen($target, "r");
# Fetch the file
while(!feof($file_handle)) {
echo fgets($file_handle, 4096);
}
fclose($file_handle);
+0
旁注:这个例子是正确的,因为很多人不知道如果在脚本结尾处不需要关闭'?>'标记。 – Cranio 2012-06-22 10:15:55
所以你不要看到输出?你能详细说明你遇到的问题吗? – JohnP 2012-03-30 16:02:42
我看到的只是它自己的实际脚本。就好像我在打字猫first.php – Sean 2012-03-30 16:05:04
只是为了确认,但你有' JohnP 2012-03-30 16:06:31