What does it mean to run PHP in quiet mode?
This only concerns the PHP interpreter built against the CGI SAPI. This version sends a few basic HTTP headers before any actual output:
X-Powered-By: PHP/5.3.3-1ubuntu9.3
Content-type: text/html
"(echo) What I actually wanted to have"
So basically the -q
commandline flag prevents any header()
from being written to stdout.
The purpose is to use the php-cgi binary in lieu of the php CLI variant for console scripts. Usually you see following shebang in such scripts to force php-cgi to behave like the -cli version:
#!/usr/bin/php-cgi -qC
How to run PHP built-in server in quiet mode?
Try this:
php -q -S 127.0.0.1:80 -t public/
use -q option for Quiet-mode
Run PHP-CLI Without Quiet Mode
Use php-cgi
instead of php
:
$ php-cgi /var/www/phptest.php
Status: 302 Moved Temporarily
X-Powered-By: PHP/5.6.32
Location: http://www.something.com
Content-type: text/html; charset=UTF-8
What is the meaning of -q in the following scripts? What differences will it make running without it?
Taken from the man php
command:
-q Quiet-mode. Suppress HTTP header output (CGI only).
See also What does it mean to run PHP in quiet mode?
How to run an external PHP script silently within a PHP script?
You can use file_get_contents()
file_get_contents("server-b.com/test.php");
or Curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "server-b.com/test.php");
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_NOBODY, TRUE); // remove body
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_exec($ch);
What does the -q PHP command-line option do?
The -q flag suppresses HTTP header output. As long as your script itself does not send anything to stdout, -q will prevent cron from sending you an email every time the script runs. For example, print and echo send to stdout. Avoid using these functions if you want to prevent cron from sending you email.
Php daemon -q switch
See command line options
-q | --no-header | Quiet-mode. Suppress HTTP header output (CGI only).
Laravel artisan tinker - quiet mode - don't print query results
Tinker dumps the output of the last command executed. So a hackish trick to suppress any output is to append a null statement:
>>> $threads = App\Thread::all(); '';
Related Topics
How to Search Array for Multiple Values in PHP
How to Use Perl Libraries from PHP
Why Do I Get "Resource Id #4" When I Apply Print_R() to an Array in PHP
PHP Include File in Webroot from File Outside Webroot
My Laravel 5.2.10 Sessions Wont Persist
How to Parse Xml Containing Custom Namespaces Using Simplexml
How to Get the File Path in HTML <Input Type="File"> in PHP
.Htaccess Mod_Rewrite > 500 Internal Server Error
How to Check If a User Is Logged-In in PHP
How to Create a .Gz File Using PHP
Using Named Parameters with Pdo for Like
Simplexml Soap Response Namespace Issues
Change Innerhtml of a PHP Domelement
File Download Script Doesn't Work When Called from Ajax
How to Make Sure That Values from MySQL Keep Their Type in PHP
Calling Perl Script from PHP and Passing in Variables, While Also Using Variablized Perl Script Name