开发者

Run one script from another on php console?

开发者 https://www.devze.com 2023-03-13 13:02 出处:网络
For example I have a simple php script. write.php <? echo \"Hello World!\"; if( $argv[\'1\'] == \'twotimes\' ) {

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

精彩评论

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