开发者

Run one script from another on php console?

For example I have a simple php script.

write.php

<?
echo "Hello World!";

if( $argv['1'] == 'twotimes' ) {
  // call write.php again with 'onetime' param (How ??)
} 

echo "Done";

?>

If I run php write.php onetime on console: It should print Hello World! only once. Print Done in the end.

If I run php write.php twotimes on console: It should print Hello World! and then call same script again to print another Hello World!. Print Done in t开发者_StackOverflow中文版he end.

How to achieve this ?

Remember: Calling the same script with different param is my objective.

Thanks


you may use php exec() funcion like this:

exec('php write.php myparam');

but it seems to me, it's a bad practice.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜