Command Line Flashcards
How can the CLI SAPI be disabled?
By using the –disable-cli option when running ./configure.
How can you determine whether you have CGI or CLI SAPI?
Type ‘php -v’ at the shell.
How does the CLI SAPI differ from other SAPIs?
- No headers are written to output, and there’s no switch to enable them.
- It does not change the working directory to that of the script.
- Plain text error messages.
- Certain php.ini directives are overridden by the CLI SAPI because they do not make sense in shell environments.
What php.ini directives are overridden by the CLI SAPI?
html_errors - defaults to false, as these can be hard to read from the command line.
implicit_flush - output is displayed immediately, and not held in a buffer.
max_execution_time - set to unlimited for the shell.
register_argc_argv - defaults to true, so that scripts executed via the CLI SAPI always have access to argc (number of arguments passed to the application) and argv (array of the actual arguments).
output_buffering - FALSE
max_input_time - FALSE; the CLI does not support GET, POST, or file uploads.
Can the CLI SAPI overridden directives be altered in php.ini or a custom .ini file?
No. However, their values can be changed during runtime.
Does the CLI SAPI change the current directory to the directory of the executed script?
No.
How can you display the list of PHP command line options?
php -h
How can you pass arguments to a script on the PHP command line?
The first argument must be –
Otherwise, PHP will interpret them as PHP options.
How can you test for syntax AND fatal errors on the command line?
With the -f switch.
On the command line, what options will not work with together with -l?
-r
How can you print built-in (and loaded) PHP and Zend modules?
php -m
How can you execute php directly on the command line?
With the -r switch.
What’s problematic about using double quotes with the -r option to execute php directly on the command line?
sh/bash performs variable substitution when using double quotes. However, variables in single-quoted strings are not expanded by sh/bash.
Is -r available in the CGI SAPI?
No.
What is the -S flag for PHP?
It starts the built-in web server.