gazolinia Posted April 9, 2010 Share Posted April 9, 2010 Hi, I have installed php as command line mode. But on running a simple script , I get output as follows without http headers. This is fine but my application needs the http header as part of printing output in console . <HTML> <HEAD> <TITLE> Hello World in PHP </TITLE> </HEAD> <BODY> Hello World </BODY> </HTML> Previously in my old php 4.1.2 I used to get like X-Powered-By: PHP/4.1.2 Content-type: text/html <HTML> <HEAD> <TITLE> Hello World in PHP </TITLE> </HEAD> <BODY> <? // Hello world in PHP print("Hello World"); ?> </BODY> </HTML> I want to get this content type as part of running >>>> php hello.php in my newer php also, for this how I need to configure. Please guide me . Thanks in advance , Jai Quote Link to comment https://forums.phpfreaks.com/topic/198102-i-installed-php-as-command-line-mode/ Share on other sites More sharing options...
trq Posted April 9, 2010 Share Posted April 9, 2010 So, change your default_mimetype directive within your php.ini. Quote Link to comment https://forums.phpfreaks.com/topic/198102-i-installed-php-as-command-line-mode/#findComment-1039403 Share on other sites More sharing options...
gazolinia Posted April 9, 2010 Author Share Posted April 9, 2010 Hi, Thanks for your kind reply . My php.ini file has default_mimetype = "text/html" ; How this need to be changed, I commented out and checked but of no use . Thanks, Jai Quote Link to comment https://forums.phpfreaks.com/topic/198102-i-installed-php-as-command-line-mode/#findComment-1039417 Share on other sites More sharing options...
trq Posted April 9, 2010 Share Posted April 9, 2010 http headers are generated by the server, I'm not real sure why you would need them generated by a cli script. Quote Link to comment https://forums.phpfreaks.com/topic/198102-i-installed-php-as-command-line-mode/#findComment-1039423 Share on other sites More sharing options...
gazolinia Posted April 9, 2010 Author Share Posted April 9, 2010 Our application work in such a way that it gets script name from browser and run the php script as part of CGI and print the output to browser. Seems little crap right but this is how it needs to work ... Please let me know how to get things work if possible. Quote Link to comment https://forums.phpfreaks.com/topic/198102-i-installed-php-as-command-line-mode/#findComment-1039584 Share on other sites More sharing options...
ddubs Posted April 9, 2010 Share Posted April 9, 2010 Make sure: # php -i | grep expose_php expose_php => On => On You can change that setting in the php.ini Quote Link to comment https://forums.phpfreaks.com/topic/198102-i-installed-php-as-command-line-mode/#findComment-1039795 Share on other sites More sharing options...
gazolinia Posted April 11, 2010 Author Share Posted April 11, 2010 Hi, Both this settings default_mime and expose_php are set as required. But even now I am not seeing headers in the output. Please verify my php -i output(Attached) and help me to figure this out. Thanks, jai [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/198102-i-installed-php-as-command-line-mode/#findComment-1039971 Share on other sites More sharing options...
Daniel0 Posted April 11, 2010 Share Posted April 11, 2010 Call the CGI binary instead of the CLI binary. This is usually called php-cgi The CLI SAPI won't output headers. It simply doesn't apply in that context. Quote Link to comment https://forums.phpfreaks.com/topic/198102-i-installed-php-as-command-line-mode/#findComment-1040008 Share on other sites More sharing options...
gazolinia Posted April 12, 2010 Author Share Posted April 12, 2010 Thanks guys. Finally I got it, I am using php-cgi instead of php as said by Daniel0. :D Quote Link to comment https://forums.phpfreaks.com/topic/198102-i-installed-php-as-command-line-mode/#findComment-1040179 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.