|
Posted by Toby A Inkster on 06/21/07 06:45
-1 wrote:
> If after the analysis in part A, data is displayed on the webpage, then it
> would display and part B would not run and the php script would terminate.
> If after the analysis in part A, data is not displayed on the webpage, then
> and only then would part B run.
Output buffering. The code below assumes that when part A fails it
literally outputs nothing -- i.e. not even a blank line or an error
message. With a bit of modification you could cope with error messages
though.
<?php
// Run part A and save contents instead of outputting it.
ob_start();
virtual('/cgi-bin/analysis.pl');
$buf = ob_get_clean();
// Check if there was no output from part A
if ($buf=='')
{
// Part B goes here.
}
// Otherwise, there was some output from part A
else
{
// So send the output to the browser.
print $buf;
}
?>
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 10:18.]
dict, thes & ency
http://tobyinkster.co.uk/blog/2007/06/18/dict-thes-ency/
Navigation:
[Reply to this message]
|