|
Posted by Erwin Moller on 12/27/06 10:11
ajh wrote:
> Using Ubuntu 5, Apache2 and PHP 4 I am trying display in a web browser
> the output from a program I wrote in C.
>
> Here is an abridged version of my code (I can post all of it later):
>
> <?php
>
> exec( "myProg -a paramA -b paramB", $output);
>
> print "<p>Returned: $return</p>";
You forgot $return in your above call. I expect you did strip your example
here. If not you would probably have received a notice about it.
(You DO have error_reporting on to the max, right? Check php.ini or make
sure you see all errors by calling ini_set() above your script.)
>
> foreach ( $output as $val ) {
> print "$val<br />";
> }
That should work.
It prints literally to the browser what the program returned.
However, this output could contain things like < starting a html-tag.
So if you actually want to see the output generated in a browser, try this:
foreach ( $output as $val ) {
echo htmlentities($val)."<br>";
}
If this wasn't the case, make sure you have error_reporting on, if that
doesn't help (= no errors/notices) come back here and please post more
code.
Regards,
Erwin Moller
>
> ?>
>
> The problem is that in the web browser only the first two lines of the
> $output appear when there should almost always more than that (usually
> around 10).
>
> I have done a test with php CLI using the same code as above: php -f
> mycode. The right/expected ouput comes out here.
>
> Any ideas how this different behaviour might be happening? Wondering if
> there is some default limit on the number of lines displayed by php in
> the browser... or if the actual lines are too long (but 100 chars isn't
> too much is it?). Thanks.
Navigation:
[Reply to this message]
|