can I suppress headers in PHP/CLI?

I have Zend Framework-based web site. When I start application from Cron I always get this output. How can I suppress such PHP headers in Zend? Or maybe it's a global PHP option?
X-Powered-By: PHP/5.2.9
Set-Cookie: PHPSESSID=a6f12eabbe240c78b7381418b4d21ce3; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-type: text/html

Open in new window

Who is Participating?
dazweejaConnect With a Mentor Commented:
I think where getting to the problem now. If you look at this page, it says that Zend_Session is (was?) not supported in the CLI environment:

So you can either run the script within a browser with your cron script (possible but a bit clunky) or maybe try putting this just before line 92 in bootstrap.php:

if (php_sapi_name() == 'cli') Zend_Session::$_unitTestEnabled = true;

Or some other code using the same check that will bypass Zend_Session if the script is run in the CLI environment.

try with this:

expose_php = Off in php.ini file.

#!/usr/local/bin/php -q

Open in new window

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

technoparkcorpAuthor Commented:
I tried both options, no effect :(
I think the -q option is what you need (as aldanch has written). Maybe the path is wrong for your installation?

Try this from a shell/command prompt:

php -q test.php
technoparkcorpAuthor Commented:
this is what I get when I use -q
<br />
<b>Fatal error</b>:  Uncaught exception 'Zend_Session_Exception' with message 'Session must be started before any output has been sent to the browser; output started in /0' in /home/xxx/library/Zend/Session.php:419
Stack trace:
#0 /home/xxx/application/bootstrap.php(92): Zend_Session::start()
#1 /home/xxx/application/Robot/run.php(22): require('/home/xxx...')
#2 {main}
  thrown in <b>/home/xxx/library/Zend/Session.php</b> on line <b>419</b><br />

Open in new window

technoparkcorpAuthor Commented:
It's always "cli", in my case it's "cgi-fcgi". Anyway it works now, thanks!
Thanks for the points. I assumed from your use of Zend_Session that this code must also be intended to be run in a browser.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.