2012-03-30 12 views
0

私は本のwebbots、spider、screen scrappersから得たこの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という文字を入力しているかのように – Sean

+1

確認するだけですが、右上に '<?php'がありますか? – 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

関連する問題