cvs: phpdoc /he/appendices commandline.xml

From: Date: Wed, 27 Feb 2002 15:13:32 +0000
Subject: cvs: phpdoc /he/appendices commandline.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969342642@lists.php.net to get a copy of this message
tal Wed Feb 27 10:13:32 2002 EDT Added files: /phpdoc/he/appendices commandline.xml Log: started working on this one, not finished

Index: phpdoc/he/appendices/commandline.xml +++ phpdoc/he/appendices/commandline.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- EN-Revision: 1.9 Maintainer: tal Status: working --> <!-- TODO: The command line options not in the list, but in the -h output below: -e, -z It would be best to document these, and collect more info about -c and -d! --> <appendix id="commandline"> <title>ùéîåù á-PHP îùåøú äô÷åãä</title> <para> àôùøåéåú ùåøú äô÷åãä ùì PHP äï éòéìåú áî÷øä ùøåöéí ìáöò ðéôåé áàâéí àå ìáãå÷ àú äú÷ðú PHP, àê äï éëåìåú ìùîù âí àí ééùåí ä-PHP àéðå îéåòã ìøùú äàéðèøðè. </para> <para> ðéúï ìäôðåú àú äôìè ùì PHP ì÷åáõ çéöåðé òì éãé ùéîåù áúå &gt;, ëìåîø, <literal>php -q test.php > test.html</literal> éëúåá àú äôìè ùì <filename>test.php</filename> ììà ëåúøåú HTTP àì úåê ÷åáõ áùí <filename>test.html/filename> áàåúä ñôøéä. </para> <para> ðéúï ìäùúîù áàôùøåéåú ùåøú äô÷åãä ø÷ àí áøùåúëí âøñä áú-äøöä ùì PHP. àí äéãøúí àú PHP áúåø øëéá ùøú (Server Module) åàéï áøùåúëí âøñú CGI, àæ ìà éäéä ðéúï ìùúîù áàôùøåéåú. áâøñú äçìåðåú ùì PHP ðëììéí âí øëéá äùøú åâí âøñä áú-äøöä. ä÷åáõ áø-ääøöä äåà <filename>php.exe</filename>. </para> <para> øùéîú àôùøåéåú ùåøú äô÷åãä îòåãëðú ìâøñä 4.0.6 ùì PHP. ðéúï ì÷áì àú äøùéîä âí òì éãé ùéîåù áàôùøåú <literal>-h</literal>. äôìè ùì <literal>php -h</literal> öøéê ìäéåú îùäå ëæä: <screen> <![CDATA[ Usage: php [-q] [-h] [-s [-v] [-i] [-f <file>] | {<file> [args...]} -q Quiet-mode. Suppress HTTP Header output. -s Display colour syntax highlighted source. -f <file> Parse <file>. Implies `-q' -v Version number -C Do not chdir to the script's directory -c <path> Look for php.ini file in this directory -d foo[=bar] Define INI entry foo with value 'bar' -e Generate extended information for debugger/profiler -z <file> Load Zend extension <file>. -l Syntax check only (lint) -m Show compiled in modules -i PHP information -h This help ]]> </screen> </para> <para> áèáìä îôåøèåú äàôùøåéåú äçùåáåú ùì PHP áùåøú äô÷åãä òí äñáøéí òìéäï. </para> <para> <table> <title>àôùøåéåú ùåøú ô÷åãä</title> <tgroup cols="2"> <thead> <row> <entry>àôùøåú</entry> <entry>úéàåø</entry> </row> </thead> <tbody> <row> <entry>-q</entry> <entry> áéèåì ëåúøåú HTTP. áãøê ëìì, PHP îãôéñä ëåúøåú HTTP òáåø äúëðéú ù÷øàä ìä (ëìåîø, ùøú Web). ëùëåúáéí ééùåí ùåøú ô÷åãä, äëåúøåú äï çñøåú òøê. </entry> </row> <row> <entry>-s</entry> <entry> äôìè éäéä ÷åã äî÷åø ùì ä÷åáõ ùöåééï òí äãâùú îéìéí ùîåøåú, îùúðéí åëå'. ãøê àçøú ìøàåú àú ä÷åã áöáòéí äéà ìäúùîù áôåð÷öéä <function>highlight_file</function> áúåê ñ÷øéôè PHP. </entry> </row> <row> <entry>-f</entry> <entry> çéôåù àçø èòåéåú áúçáéø åùâéàåú ôèàìéåú. äùéîåù äðôåõ ùì àôùøåú æå äåà áðéôåé áàâéí. </entry> </row> <row> <entry>-v</entry> <entry> äôìè éäéä äâøñä ùì PHP, áî÷øä äæä: 4.0.6. </entry> </row> <row> <entry>-C</entry> <entry> àôùøåú æå îåðòú î-PHP ìùðåú àú äñôøéä äôòéìä ìñôøéä ùáä ðîöà äñ÷øéôè ùøõ. </entry> </row> <row> <entry>-c</entry> <entry> àôùøåú æå âåøîú ì-PHP ìùàåá àú äúöåøä î÷åáõ ä- <filename>php.ini</filename> ùåðä î÷åáõ áøéøú äîçãì. </entry> </row> <row> <entry>-d</entry> <entry> òí àôùøåú æå ðéúï ì÷áåò äâãøåú INI ìñ÷øéôè äðåëçé. </entry> </row> <row> <entry>-l</entry> <entry> îöéàú èòåéåú úçáéøéåú. àôùøåú æå âí îôòéìä àú àôùøåú q-. àôùøåú æå ìà úîöà ùâéàåú ôèàìéåú. ëãé ìîöåà âí ùâéàåú ôèàìéåú, éù ìäùúîù áàôùøåú f-. </entry> </row> <row> <entry>-m</entry> <entry> Using this option, PHP prints out the built in (and loaded) PHP and Zend modules, the PHP and Zend version numbers, and a short Zend copyright notice. </entry> </row> <row> <entry>-i</entry> <entry> This command line option calls <function>phpinfo</function>, and prints out the results. If PHP is not working well, it is advisable to make a <literal>php -i</literal> and see if any error messages are printed out before or in place of the information tables. </entry> </row> <row> <entry>-h</entry> <entry> With this option, you can get information about the actual list of command line options and some one line descriptions about what they do. </entry> </row> </tbody> </tgroup> </table> </para> <para> The PHP executable can be used to run PHP scripts absolutely independent from the web server. If you are on a Unix system, you should add a special first line to your PHP script, and make it executable, so the system will know, what program should run the script. On a Windows platform you can associate <literal>php.exe -q</literal> with the double click option of the <literal>.php</literal> files, or you can make a batch file to run the script through PHP. The first line added to the script to work on Unix won't hurt on Windows, so you can write cross platform programs this way. A simple example of writing a command line PHP program can be found below. </para> <example> <title>Script intended to be run from command line (script.php)</title> <programlisting role="php"> <![CDATA[ #!/usr/bin/php -q <?php if ($argc != 2 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) { ?> This is a command line PHP script with one option. Usage: <?php echo $argv[0]; ?> <option> <option> can be some word you would like to print out. With the --help, -help, -h, or -? options, you can get this help. <?php } else { echo $argv[1]; } ?> ]]> </programlisting> </example> <para> In the script above, we used the special first line to indicate, that this file should be run by PHP and should not print out HTTP headers. There are two variables you can use while writing command line applications with PHP: <varname>$argc</varname> and <varname>$argv</varname>. The first is the number of arguments plus one (the name of the script running). The second is an array containing the arguments, starting with the script name as number zero (<varname>$argv[0]</varname>). </para> <para> In the program above we checked if there are less or more than one arguments. Also if the argument was <literal>--help</literal>, <literal>-help</literal>, <literal>-h</literal> or <literal>-?</literal>, we printed out the help message, printing the script name dynamically. If we received some other argument we echoed that out. </para> <para> If you would like to run the above script on Unix, you need to make it executable, and simply call it as <literal>script.php echothis</literal> or <literal>script.php -h</literal>. On Windows, you can make a batch file for this task: </para> <example> <title>Batch file to run a command line PHP script (script.bat)</title> <programlisting role="winbat"> @c:\php\php.exe -q script.php %1 %2 %3 %4 </programlisting> </example> <para> Assuming, you named the above program as <filename>script.php</filename>, and you have your <filename>php.exe</filename> in <filename>c:\php\php.exe</filename> this batch file will run it for you with your added options: <literal>script.bat echothis</literal> or <literal>script.bat -h</literal>. </para> <para> See also the <link linkend="ref.readline">Readline</link> extension documentation for more functions you can use to enhance your command line applications in PHP. </para> </appendix> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
« previous php.doc (#969342642) next »