2012-03-30 5 views
0

책 webbots, 거미 및 화면 스크래퍼에서 가져온이 PHP 스크립트를 실행하려고합니다.명령 줄을 사용하여 책에서 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 명령을 사용하고 있는데이 파일을 연결하면됩니다.

+0

과 같아야합니다 그래서 당신은 출력이 표시되지 않는 이유는 무엇입니까? 당신이 가진 문제에 대해 자세히 설명해 주시겠습니까? – JohnP

+0

내가 본 모든 것은 실제 스크립트 다. 마치 first.php cat을 타이핑하는 것 같습니다. – Sean

+1

확인하기 위해, 오른쪽 상단에' JohnP

답변

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); 
+0

Sidenote :이 예제는 스크립트 끝 부분에서 닫는'?>'태그가 필요 없다는 것을 모르기 때문에 정확합니다. – Cranio

관련 문제