简体   繁体   English

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

[英]Running php script from book using command line

I am trying to run this php script that i got from the book webbots, spiders, and screen scrappers. 我正在尝试运行从书本网络机器人,蜘蛛和屏幕抓取工具获得的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);

I am using the command php first.php and all it does is concatenate the file back to me. 我正在使用命令php first.php,它所做的只是将文件连接回我。

Your full script should look like this 您的完整脚本应如下所示

<?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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM