cvs: phpdoc /pt_BR/functions dir.xml exec.xml

From: Date: Tue, 17 Oct 2000 20:33:04 +0000
Subject: cvs: phpdoc /pt_BR/functions dir.xml exec.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969332516@lists.php.net to get a copy of this message
eschmid Tue Oct 17 13:33:04 2000 EDT Added files: /phpdoc/pt_BR/functions dir.xml exec.xml Log: More additions to pt_BR. Index: phpdoc/pt_BR/functions/dir.xml +++ phpdoc/pt_BR/functions/dir.xml <reference id="ref.dir"> <title>Directory functions</title> <titleabbrev>Directories</titleabbrev> <refentry id="function.chdir"> <refnamediv> <refname>chdir</refname> <refpurpose>change directory</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> <funcdef>int <function>chdir</function></funcdef> <paramdef>string <parameter>directory</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Changes PHP's current directory to <parameter>directory</parameter>. Returns FALSE if unable to change directory, TRUE otherwise. </para> </refsect1> </refentry> <refentry id="class.dir"> <refnamediv> <refname>dir</refname> <refpurpose>directory class</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> <funcdef>new <function>dir</function></funcdef> <paramdef>string <parameter>directory</parameter></paramdef> </funcprototype> </funcsynopsis> <para> A pseudo-object oriented mechanism for reading a directory. The given <parameter>directory</parameter> is opened. Two properties are available once directory has been opened. The handle property can be used with other directory functions such as <function>readdir</function>, <function>rewinddir</function> and <function>closedir</function>. The path property is set to path the directory that was opened. Three methods are available: read, rewind and close. <example> <title><function>Dir</function> Example</title> <programlisting role="php"> $d = dir("/etc"); echo "Handle: ".$d->handle."&lt;br>\n"; echo "Path: ".$d->path."&lt;br>\n"; while($entry=$d->read()) { echo $entry."&lt;br>\n"; } $d->close(); </programlisting> </example> </para> </refsect1> </refentry> <refentry id="function.closedir"> <refnamediv> <refname>closedir</refname> <refpurpose>close directory handle</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> <funcdef>void <function>closedir</function></funcdef> <paramdef>int <parameter>dir_handle</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Closes the directory stream indicated by <parameter>dir_handle</parameter>. The stream must have previously been opened by <function>opendir</function>. </para> </refsect1> </refentry> <refentry id="function.getcwd"> <refnamediv> <refname>getcwd</refname> <refpurpose>gets the current working directory</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> <funcdef>string <function>getcwd</function></funcdef> <void/> </funcprototype> </funcsynopsis> <para> Returns the current working directory. </para> </refsect1> </refentry> <refentry id="function.opendir"> <refnamediv> <refname>opendir</refname> <refpurpose>open directory handle</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> <funcdef>int <function>opendir</function></funcdef> <paramdef>string <parameter>path</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Returns a directory handle to be used in subsequent <function>closedir</function>, <function>readdir</function>, and <function>rewinddir</function> calls. </para> </refsect1> </refentry> <refentry id="function.readdir"> <refnamediv> <refname>readdir</refname> <refpurpose>read entry from directory handle</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> <funcdef>string <function>readdir</function></funcdef> <paramdef>int <parameter>dir_handle</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Returns the filename of the next file from the directory. The filenames are not returned in any particular order. <example> <title>List all files in the current directory</title> <programlisting role="php"> // Note that !== did not exist until 4.0.0-RC2 &lt;?php $handle=opendir('.'); echo "Directory handle: $handle\n"; echo "Files:\n"; while (($file = readdir($handle))!==false) { echo "$file\n"; } closedir($handle); ?&gt; </programlisting> </example> </para> <para> Note that <function>readdir</function> will return the . and .. entries. If you don't want these, simply strip them out: <example> <title> List all files in the current directory and strip out . and .. </title> <programlisting role="php"> &lt;?php $handle=opendir('.'); while (false!==($file = readdir($handle))) { if ($file != "." &amp;&amp; $file != "..") { echo "$file\n"; } } closedir($handle); ?&gt; </programlisting> </example> </para> </refsect1> </refentry> <refentry id="function.rewinddir"> <refnamediv> <refname>rewinddir</refname> <refpurpose>rewind directory handle</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> <funcdef>void <function>rewinddir</function></funcdef> <paramdef>int <parameter>dir_handle</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Resets the directory stream indicated by <parameter>dir_handle</parameter> to the beginning of the directory. </para> </refsect1> </refentry> </reference> <!-- 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 sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: --> Index: phpdoc/pt_BR/functions/exec.xml +++ phpdoc/pt_BR/functions/exec.xml <reference id="ref.exec"> <title>Program Execution functions</title> <titleabbrev>Program Execution</titleabbrev> <refentry id="function.escapeshellarg"> <refnamediv> <refname>escapeshellarg</refname> <refpurpose>escape a string to be used as a shell argument</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> <funcdef>string <function>escapeshellarg</function></funcdef> <paramdef>string <parameter>arg</parameter></paramdef> </funcprototype> </funcsynopsis> <para> <function>EscapeShellArg</function> adds single quotes around a string and quotes/escapes any existing single quotes allowing you to pass a string directly to a shell function and having it be treated as a single safe argument. This function should be used to escape individual arguments to shell functions coming from user input. The shell functions include <function>exec</function>, <function>system</function> and the <link linkend="language.operators.execution">backtick operator</link>. A standard use would be:</para> <para> <informalexample> <programlisting role="php"> system("ls ".EscapeShellArg($dir)) </programlisting> </informalexample> </para> <para> See also <function>exec</function>, <function>popen</function>, <function>system</function>, and the <link linkend="language.operators.execution">backtick operator</link>. </para> </refsect1> </refentry> <refentry id="function.escapeshellcmd"> <refnamediv> <refname>escapeshellcmd</refname> <refpurpose>escape shell metacharacters</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> <funcdef>string <function>escapeshellcmd</function></funcdef> <paramdef>string <parameter>command</parameter></paramdef> </funcprototype> </funcsynopsis> <para> <function>EscapeShellCmd</function> escapes any characters in a string that might be used to trick a shell command into executing arbitrary commands. This function should be used to make sure that any data coming from user input is escaped before this data is passed to the <function>exec</function> or <function>system</function> functions, or to the <link linkend="language.operators.execution">backtick operator</link>. A standard use would be:</para> <para> <informalexample> <programlisting role="php"> $e = EscapeShellCmd($userinput); system("echo $e"); // here we don't care if $e has spaces $f = EscapeShellCmd($filename); system("touch \"/tmp/$f\"; ls -l \"/tmp/$f\""); // and here we do, so we use quotes </programlisting> </informalexample> </para> <para> See also <function>escapeshellarg</function>, <function>exec</function>, <function>popen</function>, <function>system</function>, and the <link linkend="language.operators.execution">backtick operator</link>. </para> </refsect1> </refentry> <refentry id="function.exec"> <refnamediv> <refname>exec</refname> <refpurpose>Execute an external program</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> <funcdef>string <function>exec</function></funcdef> <paramdef>string <parameter>command</parameter></paramdef> <paramdef>string <parameter><optional>array</optional> </parameter> </paramdef> <paramdef>int <parameter><optional>return_var</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>exec</function> executes the given <parameter>command</parameter>, however it does not output anything. It simply returns the last line from the result of the command. If you need to execute a command and have all the data from the command passed directly back without any interference, use the <function>PassThru</function> function. </para> <para> If the <parameter>array</parameter> argument is present, then the specified array will be filled with every line of output from the command. Note that if the array already contains some elements, <function>exec</function> will append to the end of the array. If you do not want the function to append elements, call <function>unset</function> on the array before passing it to <function>exec</function>. </para> <para> If the <parameter>return_var</parameter> argument is present along with the <parameter>array</parameter> argument, then the return status of the executed command will be written to this variable. </para> <para> Note that if you are going to allow data coming from user input to be passed to this function, then you should be using <function>EscapeShellCmd</function> to make sure that users cannot trick the system into executing arbitrary commands. </para> <para> Note also that if you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends. </para> <para> See also <function>system</function>, <function>PassThru</function>, <function>popen</function>, <function>EscapeShellCmd</function>, and the <link linkend="language.operators.execution">backtick operator</link>. </para> </refsect1> </refentry> <refentry id="function.passthru"> <refnamediv> <refname>passthru</refname> <refpurpose> Execute an external program and display raw output </refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> <funcdef>void <function>passthru</function></funcdef> <paramdef>string <parameter>command</parameter></paramdef> <paramdef>int <parameter><optional>return_var</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> The <function>passthru</function> function is similar to the <function>Exec</function> function in that it executes a <parameter>command</parameter>. If the <parameter>return_var</parameter> argument is present, the return status of the Unix command will be placed here. This function should be used in place of <function>Exec</function> or <function>System</function> when the output from the Unix command is binary data which needs to be passed directly back to the browser. A common use for this is to execute something like the pbmplus utilities that can output an image stream directly. By setting the content-type to <emphasis>image/gif</emphasis> and then calling a pbmplus program to output a gif, you can create PHP scripts that output images directly.</para> <para> Note that if you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends. </para> <para> See also <function>exec</function>, <function>system</function>, <function>popen</function>, <function>EscapeShellCmd</function>, and the <link linkend="language.operators.execution">backtick operator</link>. </para> </refsect1> </refentry> <refentry id="function.system"> <refnamediv> <refname>system</refname> <refpurpose>Execute an external program and display output</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> <funcdef>string <function>system</function></funcdef> <paramdef>string <parameter>command</parameter></paramdef> <paramdef>int <parameter><optional>return_var</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> <function>System</function> is just like the C version of the function in that it executes the given <parameter>command</parameter> and outputs the result. If a variable is provided as the second argument, then the return status code of the executed command will be written to this variable. </para> <para> Note, that if you are going to allow data coming from user input to be passed to this function, then you should be using the <function>EscapeShellCmd</function> function to make sure that users cannot trick the system into executing arbitrary commands. </para> <para> Note also that if you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends. </para> <para> The <function>System</function> call also tries to automatically flush the web server's output buffer after each line of output if PHP is running as a server module. </para> <para> Returns the last line of the command output on success, and false on failure. </para> <para> If you need to execute a command and have all the data from the command passed directly back without any interference, use the <function>PassThru</function> function. </para> <para> See also <function>exec</function>, <function>PassThru</function>, <function>popen</function>, <function>EscapeShellCmd</function>, and the <link linkend="language.operators.execution">backtick operator</link>. </para> </refsect1> </refentry> </reference> <!-- 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 sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: -->

« previous php.doc (#969332516) next »