david Sat Dec 28 06:09:30 2002 EDT Modified files: /phpdoc/en/features commandline.xml Log: fix some typos/clarification
Index: phpdoc/en/features/commandline.xml diff -u phpdoc/en/features/commandline.xml:1.15 phpdoc/en/features/commandline.xml:1.16 --- phpdoc/en/features/commandline.xml:1.15 Fri Dec 27 19:42:31 2002 +++ phpdoc/en/features/commandline.xml Sat Dec 28 06:09:30 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.15 $ --> +<!-- $Revision: 1.16 $ --> <chapter id="features.commandline"> <title>Using PHP from the command line</title> <!-- NEW DOCUMENTATION STARTS --> @@ -11,7 +11,7 @@ main focus is on developing shell (or desktop as well) applications with <literal>PHP</literal>. There are quite a few differences between the <literal>CLI SAPI</literal> and other <literal>SAPI</literal>s which are - further explained throughout this chapter. It's worth mentioning + explained in this chapter. It's worth mentioning that <literal>CLI</literal> and <literal>CGI</literal> are different SAPI's although they do share many of the same behaviors. </para> @@ -59,7 +59,7 @@ <note> <title>What SAPI do I have?</title> <para> - While in shell, by typing <literal>php -v</literal> it will tell you + From a shell, typing <literal>php -v</literal> will tell you whether <literal>php</literal> is CGI or CLI. See also the function <function>php_sapi_name</function> and the constant <constant> PHP_SAPI</constant>. @@ -75,25 +75,25 @@ output. </para> <para> - Though the <literal>CGI SAPI</literal> provies a way to suppress HTTP - headers, there's not equivalent switch to enable them in the <literal>CLI + Though the <literal>CGI SAPI</literal> provides a way to suppress HTTP + headers, there's no equivalent switch to enable them in the <literal>CLI SAPI</literal>. </para> <para> - CLI is started up in quiet mode by default. But <literal>-q</literal> - switch is kept for compatibility so that you can use older CGI scripts. + CLI is started up in quiet mode by default, though the <literal>-q</literal> + switch is kept for compatibility so that you can use older CGI scripts. </para> <para> - It does not change the working directory to that of the script. - (<literal>-C</literal> switch kept for compatibility) + It does not change the working directory to that of the script. + (<literal>-C</literal> switch kept for compatibility) </para> <para> - Plain text error messages (no HTML formatting). + Plain text error messages (no HTML formatting). </para> </listitem> <listitem> <para> - The are certain &php.ini; directives which are overriden by the <literal>CLI + There are certain &php.ini; directives which are overriden by the <literal>CLI SAPI</literal> because they do not make sense in shell environments: <table> <title>Overriden &php.ini; directives</title> @@ -121,7 +121,7 @@ <entry> It is desired that any output coming from <function>print</function>, <function>echo</function> and friends is - immidiately written to the output and not cached in any buffer. You + immediately written to the output and not cached in any buffer. You still can use <link linkend="ref.outcontrol">output buffering</link> if you want to defer or manipulate standard output. </entry> @@ -132,8 +132,8 @@ <entry> Due to endless possibilities of using <literal>PHP</literal> in shell environments, the maximum execution time has been set to - unlimited. Whereas applications written for the web are executed - within splits of a seconds, shell application tend to have a much + unlimited. Whereas applications written for the web are often + executed very quickly, shell application tend to have a much longer execution time. </entry> </row> @@ -150,13 +150,13 @@ <para> As of PHP 4.3.0, the <literal>PHP</literal> variables <literal>$argc</literal> and <literal>$argv</literal> are registered and filled in with the appropriate - values when using the <literal>CLI SAPI</literal>. Before this time + values when using the <literal>CLI SAPI</literal>. Prior to this version, the creation of these variables behaved as they do in <literal>CGI</literal> and <literal>MODULE</literal> versions which requires the PHP directive <link linkend="ini.register-globals">register_globals</link> to be <emphasis>on</emphasis>. Regardless of version or register_globals - setting you can always go through either + setting, you can always go through either <link linkend="reserved.variables.server">$_SERVER</link> or <varname>$HTTP_SERVER_VARS</varname>. Example: <varname>$_SERVER['argv']</varname> @@ -169,7 +169,7 @@ </para> <note> <para> - These directives cannot be initialzied with another value from the + These directives cannot be initialized with another value from the configuration file &php.ini; or a custom one (if specified). This is a limitation because those default values are applied after all configuration files have been parsed. However, their value can be changed @@ -233,8 +233,8 @@ <programlisting role="php"> php -r 'fwrite(STDERR, "stderr\n");' </programlisting> - You do not need to explicitly close these streams, this is automatically - done by <literal>PHP</literal>. + You do not need to explicitly close these streams, as they are closed + automatically by <literal>PHP</literal> when your script ends. </para> </listitem> <listitem> @@ -285,7 +285,7 @@ <note> <para> The <literal>CGI SAPI</literal> supports the <literal>CLI SAPI</literal> - behaviour by means of the <literal>-C</literal> switch when ran from the + behaviour by means of the <literal>-C</literal> switch when run from the command line. </para> </note> @@ -337,11 +337,11 @@ php -f my_script.php ]]> </screen> - Both ways (using the <literal>-f</literal> switch or not) execute the - given file <filename>my_script.php</filename>. You can choose any file to - execute, your <literal>PHP</literal> scripts do not have to end with the - <filename>.php</filename> extension but can give them any name or extension - you want them to have. + Both ways (whether using the <literal>-f</literal> switch or not) execute + the file <filename>my_script.php</filename>. You can choose any file to + execute - your <literal>PHP</literal> scripts do not have to end with the + <filename>.php</filename> extension but can have any name or extension + you wish. </para> </listitem> <listitem> @@ -360,7 +360,7 @@ </para> <note> <para> - Read the example carefully, thera are no beginning or ending tags! The + Read the example carefully, there 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> @@ -387,10 +387,10 @@ </para> <para> Like every shell application, the <literal>PHP</literal> binary - 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 + accepts a number of arguments but your <literal>PHP</literal> script can + also receive arguments. 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 the number 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 @@ -405,10 +405,10 @@ 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> - itself thinks it has to handle it. To prevent this use the argument list - separator <literal>--</literal>. After the argument has been parsed by + itself thinks it has to handle it. To prevent this, use the argument list + separator <literal>--</literal>. After this separator has been parsed by <literal>PHP</literal>, every argument following it is passed - untoched/unparsed to your script. + untouched to your script. </para> <screen> <![CDATA[ @@ -430,11 +430,11 @@ <para> However, there's another way of using <literal>PHP</literal> for shell scripting. You can write a script where the 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 - appropriately. This way it can be executed like a normal shell or perl - script: + <literal>#!/usr/bin/php</literal>. Following this you can place + normal <literal>PHP</literal> code included within the <literal>PHP</literal> + starting and end tags. Once you have set the execution attributes of the file + appropriately (e.g. <literal>chmod +x test</literal>) your script can be + executed like a normal shell or perl script: <programlisting role="php"> <![CDATA[ #!/usr/bin/php @@ -461,8 +461,8 @@ } ]]> </screen> - As you see no care has to be taken when passing parameters to your script - which start with <literal>-</literal>. + As you see, in this case no care needs to be taken when passing parameters + which start with <literal>-</literal> to your script. </para> <para> <table> @@ -568,7 +568,7 @@ <entry>-d</entry> <entry> <para> - This option allows to set a custom value for any of the configuration + This option allows you to set a custom value for any of the configuration directives allowed in &php.ini;. The syntax is: <screen> <![CDATA[ @@ -580,7 +580,7 @@ Examples: <screen> <![CDATA[ -# Ommiting the value part will set the given configuration directive to "1" +# Omitting the value part will set the given configuration directive to "1" $ php -d max_execution_time -r '$foo = ini_get("max_execution_time"); var_dump($foo);' string(1) "1" @@ -680,8 +680,8 @@ <entry>-i</entry> <entry> This command line option calls <function>phpinfo</function>, and prints - out the results. If <literal>PHP</literal> is not working well, it is - advisable to make a <literal>php -i</literal> and see if any error + out the results. If <literal>PHP</literal> is not working correctly, it is + advisable to use <literal>php -i</literal> and see whether any error messages are printed out before or in place of the information tables. Beware that the output is in <literal>HTML</literal> and therefore quite huge. @@ -695,7 +695,7 @@ within the command line. The <literal>PHP</literal> start and end tags (<literal><?php</literal> and <literal>?></literal>) are <emphasis role="strong">not needed</emphasis> and will cause a parser - errors. + error if present. </para> <note> <para> @@ -711,18 +711,18 @@ Command line code(1) : Parse error - parse error, unexpected '=' ]]> </screen> - The problem here is that the sh/bash performs variable substritution + The problem here is that the sh/bash performs variable substitution 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 - <literal>PHP</literal> for executin in fact reads: + expands to nothing which results in the code passed to + <literal>PHP</literal> for execution actually reading: <screen> <![CDATA[ $ php -r " = get_defined_constants();" ]]> </screen> The correct way would be to use single quotes <literal>'</literal>. - variables in strings quoted with single quotes are not expanded + Variables in single-quoted strings are not expanded by sh/bash. <screen> <![CDATA[ @@ -744,7 +744,7 @@ further issues. Feel free to open a bug report or send a mail to [EMAIL PROTECTED] - One still can easily run intro troubles when trying to get shell + One can still easily run into troubles when trying to get shell variables into the code or using backslashes for escaping. You've been warned. <!-- :-) --> </para> @@ -973,7 +973,7 @@ </programlisting> </example> <para> - In the script above, we used the special first line to indicate, + In the script above, we used the special first line to indicate that this file should be run by PHP. We work with a CLI version here, so there will be no HTTP header printouts. There are two variables you can use while writing command line applications with @@ -1003,7 +1003,7 @@ </programlisting> </example> <para> - Assuming, you named the above program as + Assuming you named the above program <filename>script.php</filename>, and you have your CLI <filename>php.exe</filename> in <filename>c:\php\cli\php.exe</filename> this batch file
-- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php