2012-04-12 8 views
0

私はPHPスクリプトscript1.phpを持っています。私はscript2.phpに引数を渡し、script1.phpから引数を実行したいと思います。 (script2.phpがscript1.phpで使用されているテキストファイルに出力を保存)パラメータを渡して別の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 

を取得します。

答えて

1

あなたは単にscript1.php内script2.phpを含むことができ、あなたはscript2.phpにパラメータを渡す必要はありません

include 'script2.php'; 

include文の前に存在する変数はスクリプト2で利用できるようになります。 PHPは正常です。そして、あなたはあなたの中に、実行後にファイルを読み取ることができるシステムコマンドに

<?php 
`script1.php any_command_line_options_goes_here`; 

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

を呼び出すために

+0

のplsをscript1.php私の編集した質問 – jacksparrow007

0

使用バッククォートは

+0

私はあなたが質問を誤解したと思うをチェック。 –

+0

私が探していた答えが見つかりました '$ data = file_get_contents( 'http://domain.com/a.php?this=that&that=this');' – jacksparrow007

+0

@BenEverard – lexabug

関連する問題