du155305
du155305
2011-12-22 23:03

如果你在php中使用shell_exec函数,是否可以获取和提取数组

  • php

I have a php script, let's call it main_script.php and if you run it through a console it returns bunch of interesting data.

I have another script, let's call it second_script.php. in second_script.php I am using shell_exec command such as

$main_script = "php main_script.php --array=true";
$output = $shell_exec($main_script);

That will, however, return output from main_script.php

What if I want main_script.php return an array. Something like this

if ($con->console_parm['array'] ){
   $whatever = array("test"=> "data son!");
   return $whatever;
}

Is there a way I can execute it through second_script.php and get that array?!

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答