PHP system function strange behavior
I have a strange behavior with PHP system function. In this php script there are only 2 instructions (the rest being pure html):
<?php echo system('cgi-bin/gallery2/galleryheaderview.cgi'); ?>
<?php echo system('cgi-bin/gallery2/galleryview.cgi'); ?>
The first cgi just returns a single line as you can check here http://reboltutorial.com/cgi-bin/gallery2/galleryheaderview.cgi
It returns
My Gallery
But the whole php script returns My Gallery Twice:
My Gallery My Gallery
http://reboltutorial.com/gallery2.php
Is there a reason (I don't开发者_Go百科 use My Gallery in second cgi script of course see http://reboltutorial.com/cgi-bin/gallery2/galleryview.cgi) and how to prevent this ?
Thanks.
Update: The system
function will do two things. The first is, it will run a command and pass its output through to the browser and/or output buffer. The second is, it will return the last line of output. So when you're saying
echo system('/...');
You're saying "Hey system
, output the results of this command" and then "Hey ehco, output whatever system
returns". Removing the echo
system('/...');
will fix your problem.
A few other things to check
Are you sure its
galleryheaderview.cgi
that's returning things twice? Comment out the include to make sure its actually the script that's echoing My Gallery twiceIs your PHP page/program included/constructed in such a way that
galleryheaderview.cgi
is being called twice?Are you sure that calling the URL
http://reboltutorial.com/cgi-bin/gallery2/galleryheaderview.cgi
is calling the same command line ascgi-bin/gallery2/galleryheaderview.cgi
?
If you've checked out the three items above, you'll need to drop into the source of galleryheaderview.cgi
and see why its outputting the header twice.
Are you absolutely sure that nothing else is outputting the My Gallery before this line? You should try removing it, and see if it goes completely away or if there is still is one "My Gallery"
<?php echo system('cgi-bin/gallery2/galleryheaderview.cgi'); ?>
If this doesn't bring you any further, maybe you have included some php file twice?
精彩评论