cvs: phpdoc /en/features commandline.xml

From: Date: Fri, 10 May 2002 22:08:57 +0000
Subject: cvs: phpdoc /en/features commandline.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969345429@lists.php.net to get a copy of this message
jan Fri May 10 18:08:57 2002 EDT Modified files: /phpdoc/en/features commandline.xml Log: - minor improvements # Nice work Markus! Index: phpdoc/en/features/commandline.xml diff -u phpdoc/en/features/commandline.xml:1.2 phpdoc/en/features/commandline.xml:1.3 --- phpdoc/en/features/commandline.xml:1.2 Fri May 10 17:11:05 2002 +++ phpdoc/en/features/commandline.xml Fri May 10 18:08:56 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <chapter id="features.commandline"> <title>Using PHP from the command line</title> <!-- NEW DOCUMENTATION STARTS --> @@ -148,7 +148,7 @@ /tmp ]]> </screen> - This allows for greater flexibility when writing shell tools in + This allows greater flexibility when writing shell tools in <literal>PHP</literal>. </para> <note> @@ -229,7 +229,7 @@ </para> <note> <para> - Read the example carefully, thera are no beginning or end tags! The + Read the example carefully, thera are no beginning or ending tags! The <literal>-r</literal> switch simply does not need them. Using them will lead to a parser error. </para> @@ -237,7 +237,7 @@ </listitem> <listitem> <para> - Provide the <literal>PHP</literal> code to execute via standard input + Provide the <literal>PHP</literal> code to execute via standard input (<literal>stdin</literal>). </para> <para> @@ -259,7 +259,7 @@ accepts a number of arguments but also your <literal>PHP</literal> script can receive them. The number of arguments which can be passed to your script is not limited by <literal>PHP</literal> (the shell has a certain size limit - in numbers of characters which can be passed, usually you won't hit this + in numbers of characters which can be passed; usually you won't hit this limit). The arguments passed to your script are available in the global array <literal>$argv</literal>. The zero index always contains the script name (which is <literal>-</literal> in case the <literal>PHP</literal> code @@ -271,11 +271,11 @@ </para> <para> As long as the arguments you want to pass to your script do not start with - the <literal>-</literal> character, there's nothing special to whatch out + the <literal>-</literal> character, there's nothing special to watch out for. Passing an argument to your script which starts with a <literal>-</literal> will cause trouble because <literal>PHP</literal> thinks it has to handle it. To prevent this use the argument list separator - <literal>--</literal>. After argument has been parsed by + <literal>--</literal>. After the argument has been parsed by <literal>PHP</literal>, every argument following it is passed untoched/unparsed to your script. </para> @@ -297,8 +297,8 @@ ]]> </screen> <para> - But, there's another way of using <literal>PHP</literal> for shell - scripting. You can write a script whose first line starts with + However, there's another way of using <literal>PHP</literal> for shell + scripting. You can write a script which's first line starts with <literal>#!/usr/bin/php</literal> and then following the normal <literal>PHP</literal> code included within the <literal>PHP</literal> starting and end tags and set the execution attributes of the file @@ -393,11 +393,13 @@ <entry>-v</entry> <entry> <para> - Writes the PHP and Zend version to standard output, e.g. + Writes the PHP, PHP SAPI, and Zend version to standard output, e.g. <screen> +<![CDATA[ $ php -v PHP 4.3.0-dev (cli) Zend Engine v1.2.1, Copyright (c) 1998-2002 Zend Technologies +]]> </screen> </para> </entry> @@ -410,9 +412,11 @@ &php.ini; or you can specify a custom <literal>INI</literal> file directly (which does not need to be named &php.ini;), e.g.: <screen> +<![CDATA[ $ php -c /custom/directory/ my_script.php $ php -c /custom/directory/custom-file.ini my_script.php +]]> </screen> </para> </entry> @@ -481,9 +485,9 @@ <para> Load Zend extension. If only a filename is given, PHP tries to load this extension from the current default library path on your system - (usually specified <filename>/etc/ld.so.conf</filename> on Unix + (usually specified <filename>/etc/ld.so.conf</filename> on Linux systems). Passing a filename with an absolute path information will - not use the systems library search path. A relative filename with a + not use the systems library search path. A relative filename with a directory information will tell <literal>PHP</literal> only to try to load the extension relative to the current directory. </para> @@ -521,6 +525,7 @@ Using this option, PHP prints out the built in (and loaded) PHP and Zend modules: <screen> +<![CDATA[ $ php -m [PHP Modules] xml @@ -535,7 +540,7 @@ ctype [Zend Modules] - +]]> </screen> </para> </entry> @@ -575,7 +580,7 @@ Command line code(1) : Parse error - parse error, unexpected '=' ]]> </screen> - The problem here is that the shell performs variable substritution + The problem here is that the sh/bash performs variable substritution even when using double quotes <literal>"</literal>. Since the variable <literal>$foo</literal> is unlikely to be defined, it expands to nothing which results in being the code passed to @@ -586,8 +591,8 @@ ]]> </screen> The correct way would be to use single quotes <literal>'</literal>. - The shell doesn't expand variables in strings quoted with single - quotes: + variables in strings quoted with single quotes are not expanded + by sh/bash. <screen> <![CDATA[ $ php -r '$foo = get_defined_constants(); var_dump($foo);' @@ -604,6 +609,10 @@ [...] ]]> </screen> + If you are using a shell different from sh/bash, you might experience + further issues. Feel free to open a bug report or send a mail to + phpdoc@lists.php.net. + One still can easily run intro troubles when trying to get shell variables into the code or using backslashes for escaping. You've been warned. <!-- :-) -->

« previous php.doc (#969345429) next »