使用命令行从书中运行php脚本

时间:2012-03-30 16:00:44

标签: php linux command-line debian

我正在尝试运行这个来自书籍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,它所做的只是将文件连接回我。

1 个答案:

答案 0 :(得分:1)

您的完整脚本应如下所示

<?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);
相关问题