0

私はphpスクリプトscript1.phpを持っています。script2.phpに引数を渡し、script1.phpから実行したいと思います。(script2.phpは、script1.phpで使用されるテキストファイルに出力を保存します)

編集:

これは私のscript2.phpです

require_once('showtimes/simple_html_dom/simple_html_dom.php');

$html = new simple_html_dom();
//$requested4=$_GET['place'];
$html->load_file('http://www.google.com/movies?near=${requested4}&hl=en');
ob_start(); 

$muv='<pre>';
foreach($html->find('#movie_results .theater') as $div) {
    // print theater and address info
$muv=$muv."Theatre:  ".$div->find('h2 a',0)->innertext."\n";
$muv=$muv."Address: ". $div->find('.info',0)->innertext."\n";

    // print all the movies with showtimes
    foreach($div->find('.movie') as $movie) {
       $muv=$muv."\tMovie:    ".$movie->find('.name a',0)->innertext.'<br />';
      $muv=$muv."\tTime:    ".$movie->find('.times',0)->innertext.'<br />';
    }
    $muv=$muv. "\n\n";
}
$muv=$muv."</pre>";
//ob_get_contents(); 
ob_end_clean(); 
echo $muv;
file_put_contents('textfiles/file.txt', $muv);  
$html->clear();

?>

これを実行するだけで正常に動作しますが、script1.phpに含めるとこのエラーが発生します

Fatal error: Call to a member function find() on a non-object in /home/anandheg/public_html/anandghegde.in/se/showtimes/simple_html_dom/simple_html_dom.php on line 879

また、シェルを実行するためのサーバーに対する権限がありません。

4

2 に答える 2

1

script1.php内にscript2.phpを含めることができます

include 'script2.php';

ステートメントが通常どおりscript2.phpで使用可能になるscript2.php前に存在する変数に、パラメーターを渡す必要はありません。include

于 2012-04-12T12:49:32.870 に答える
1

システムコマンドを呼び出すためにバッククォートを使用する

<?php
`script1.php any_command_line_options_goes_here`;

//example
`/usr/bin/php -i`;

次に、script1.phpで実行後にファイルを読み取ることができます

于 2012-04-12T12:51:13.837 に答える