php中的shell_exec输出检测eol

时间:2015-05-19 18:01:24

标签: php python

我想分析一下我从php shell_exec获得的不同行。我有以下代码:

<?php
$output = shell_exec("sudo python /home/pi/compteur/compteur.py -o /var/www/photo/photo -f 2>&1");

echo $output;
$output2 = explode ('\n',$output);
echo "<PRE>".$output2."</PRE>";
?>

所以我的python脚本正在编写很多东西,从第一个echo开始,我看到所有的行,但在浏览器的一行中。随着爆炸,我尝试了其他的东西,但我没有得到任何东西,我从第二个回声中看到的唯一的东西是数组,然后没有别的。我希望将输出作为一个数组,以便我可以遍历每一行并根据结果采取行动。

1 个答案:

答案 0 :(得分:0)

您可以将public function debugAction() { $em = $this->getDoctrine()->getManager(); $post = $em->getRepository('NewsBundle:Post')->findOneById(31); \Doctrine\Common\Util\Debug::dump($post->getTranslations()->toArray()); return $this->render('CoreBundle:Test:test.html.twig', array( )); } 与第二个参数一起使用。