Page 1 of 1
Prevent output from a script
Posted: Fri Apr 07, 2006 3:52 am
by jmut
Hi I have one script that is used for somthing.
But I will use it in a cronjob so I want it to produce no output (dev/null of the script is no opion).
Code: Select all
foreach ($someting as $data) {
include("script_that_produce_output_I_dont_need");
}
Posted: Fri Apr 07, 2006 4:13 am
by shiznatix
if you use output functions like echo() or somthing then it is going to produce output, no way of avoiding that. Also, use error_reporting(E_NONE) so no errors are outputted.
Posted: Fri Apr 07, 2006 4:54 am
by timvw
With
http://www.php.net/ob_start and
http://www.php.net/ob_flush you can prevent (most of) the output... Now cross your fingers and hope that there are no headers being generated...
Posted: Fri Apr 07, 2006 5:46 am
by jmut
well there are echos and var_dumps and stuff

I don't see how there will be no headers generated.
Posted: Fri Apr 07, 2006 5:50 am
by jmut
found a solution.
using curl and don't output any result from it
Posted: Fri Apr 07, 2006 7:31 am
by feyd
timvw's direction is the general way to go. Using curl can involve a lot of extra overhead that you shouldn't really need.
Posted: Fri Apr 07, 2006 10:03 am
by jmut
feyd wrote:timvw's direction is the general way to go. Using curl can involve a lot of extra overhead that you shouldn't really need.
yes but what about the headers.
"Now cross your fingers and hope that there are no headers being generated..."
I mention there are plenty of echos and stuff
Posted: Fri Apr 07, 2006 10:06 am
by feyd
If there are lots of echos, typically there is no extra headers being set for a lot of people. You could always make sure to override the headers after including the file too.