cvs: phpdoc /en/reference/filesystem/figures readfile.png /en/reference/filesystem/functions chgrp.xml clearstatcache.xml fflush.xml fgetss.xml
filegroup.xml fileinode.xml fileowner.xml ftruncate.xml lchgrp.xml lchown.xml link.xml move-uploaded-file.xml pclose.xml readfile.xml rewind.xml
rmdir.xml
| From: | Ross Masters | Date: | Mon, 13 Oct 2008 19:26:50 +0000 |
| Subject: | cvs: phpdoc /en/reference/filesystem/figures readfile.png /en/reference/filesystem/functions chgrp.xml clearstatcache.xml fflush.xml fgetss.xml filegroup.xml fileinode.xml fileowner.xml ftruncate.xml lchgrp.xml lchown.xml link.xml move-uploaded-file.xml pclose.xml readfile.xml rewind.xml rmdir.xml |
||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-2227@lists.php.net to get a copy of this message | ||
ross Mon Oct 13 19:26:50 2008 UTC
Added files:
/phpdoc/en/reference/filesystem/figures readfile.png
Modified files:
/phpdoc/en/reference/filesystem/functions chgrp.xml
clearstatcache.xml
fflush.xml fgetss.xml
filegroup.xml
fileinode.xml
fileowner.xml
ftruncate.xml lchgrp.xml
lchown.xml link.xml
move-uploaded-file.xml
pclose.xml readfile.xml
rewind.xml rmdir.xml
Log:
Added examples for all functions.
Added forced download image for readfile example.
Added see also links for the following:
- flush
- fileowner
- rewind
- rmdir
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/chgrp.xml?r1=1.9&r2=1.10&diff_format=u Index: phpdoc/en/reference/filesystem/functions/chgrp.xml diff -u phpdoc/en/reference/filesystem/functions/chgrp.xml:1.9 phpdoc/en/reference/filesystem/functions/chgrp.xml:1.10 --- phpdoc/en/reference/filesystem/functions/chgrp.xml:1.9 Wed Jun 20 22:24:27 2007 +++ phpdoc/en/reference/filesystem/functions/chgrp.xml Mon Oct 13 19:26:49 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.chgrp"> <refnamediv> <refname>chgrp</refname> @@ -54,6 +54,25 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Changing a file's group</title> + <programlisting role="php"> +<![CDATA[ +<?php +$filename = 'shared_file.txt'; +echo("$filename's Group ID @ " . time() . ": " . filegroup($filename) . "\n"); +chgrp($filename, 8); +echo("$filename's Group ID @ " . time() . ": " . filegroup($filename) . "\n"); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.no-remote; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/clearstatcache.xml?r1=1.13&r2=1.14&diff_format=u Index: phpdoc/en/reference/filesystem/functions/clearstatcache.xml diff -u phpdoc/en/reference/filesystem/functions/clearstatcache.xml:1.13 phpdoc/en/reference/filesystem/functions/clearstatcache.xml:1.14 --- phpdoc/en/reference/filesystem/functions/clearstatcache.xml:1.13 Thu Aug 16 15:48:12 2007 +++ phpdoc/en/reference/filesystem/functions/clearstatcache.xml Mon Oct 13 19:26:49 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.13 $ --> +<!-- $Revision: 1.14 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.clearstatcache"> <refnamediv> <refname>clearstatcache</refname> @@ -68,6 +68,45 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>clearstatcache</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$file = 'output_log.txt'; + +function get_owner($file) +{ + $stat = stat($file); + $user = posix_getpwuid($s['uid']); + return $user['name']; +} + +echo('UID @ ' . date('r') . ': ' . get_owner($file) . PHP_EOL); + +chown($path, 'ross'); +echo('UID @ ' . date('r') . ': ' . get_owner($file) . PHP_EOL); + +clearstatcache(); +echo('UID @ ' . date('r') . ': ' . get_owner($file) . PHP_EOL); +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +UID @ Sun, 12 Oct 2008 20:48:28 +0100: root +UID @ Sun, 12 Oct 2008 20:48:28 +0100: root +UID @ Sun, 12 Oct 2008 20:48:28 +0100: ross +]]> + </screen> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/fflush.xml?r1=1.9&r2=1.10&diff_format=u Index: phpdoc/en/reference/filesystem/functions/fflush.xml diff -u phpdoc/en/reference/filesystem/functions/fflush.xml:1.9 phpdoc/en/reference/filesystem/functions/fflush.xml:1.10 --- phpdoc/en/reference/filesystem/functions/fflush.xml:1.9 Wed Jun 20 22:24:27 2007 +++ phpdoc/en/reference/filesystem/functions/fflush.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.fflush"> <refnamediv> <refname>fflush</refname> @@ -39,6 +39,39 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>File write example using <function>fflush</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +$filename = 'bar.txt'; + +$file = fopen($filename, 'r+'); +rewind($file); +fwrite($file, 'Foo'); +fflush($file); +ftruncate($file, ftell($file)); +fclose($file); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>clearstatcache</function></member> + <member><function>fwrite</function></member> + </simplelist> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/fgetss.xml?r1=1.9&r2=1.10&diff_format=u Index: phpdoc/en/reference/filesystem/functions/fgetss.xml diff -u phpdoc/en/reference/filesystem/functions/fgetss.xml:1.9 phpdoc/en/reference/filesystem/functions/fgetss.xml:1.10 --- phpdoc/en/reference/filesystem/functions/fgetss.xml:1.9 Sun Jul 1 21:31:16 2007 +++ phpdoc/en/reference/filesystem/functions/fgetss.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.fgetss"> <refnamediv> <refname>fgetss</refname> @@ -94,6 +94,45 @@ </para> </refsect1> + <refsect1 role="examples"> + <para> + <example> + <title>Reading a PHP file line-by-line</title> + <programlisting role="php"> +<![CDATA[ +<?php +$str = <<<EOD +<html><body> + <p>Welcome! Today is the <?php echo(date('jS')); ?> of <?= date('F'); ?>.</p> +</body></html> +Text outside of the HTML block. +EOD; +file_put_contents('sample.php', $str); + +$handle = @fopen("sample.php", "r"); +if($handle) { + while(!feof($handle)) + { + $buffer = fgetss($handle, 4096); + echo $buffer; + } + fclose($handle); +} +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ + Welcome! Today is the of . + +Text outside of the HTML block. +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.line-endings; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/filegroup.xml?r1=1.9&r2=1.10&diff_format=u Index: phpdoc/en/reference/filesystem/functions/filegroup.xml diff -u phpdoc/en/reference/filesystem/functions/filegroup.xml:1.9 phpdoc/en/reference/filesystem/functions/filegroup.xml:1.10 --- phpdoc/en/reference/filesystem/functions/filegroup.xml:1.9 Wed Jun 20 22:24:27 2007 +++ phpdoc/en/reference/filesystem/functions/filegroup.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.filegroup"> <refnamediv> <refname>filegroup</refname> @@ -44,6 +44,23 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Finding the group of a file</title> + <programlisting role="php"> +<![CDATA[ +<?php +$filename = 'index.php'; +print_r(posix_getgrgid(filegroup($filename))); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="errors"> &reftitle.errors; <para> @@ -62,6 +79,7 @@ <para> <simplelist> <member><function>fileowner</function></member> + <member><function>posix_getgrgid</function></member> <member><link linkend="ini.safe-mode-gid">safe_mode_gid</link></member> </simplelist> </para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/fileinode.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/filesystem/functions/fileinode.xml diff -u phpdoc/en/reference/filesystem/functions/fileinode.xml:1.8 phpdoc/en/reference/filesystem/functions/fileinode.xml:1.9 --- phpdoc/en/reference/filesystem/functions/fileinode.xml:1.8 Wed Jun 20 22:24:27 2007 +++ phpdoc/en/reference/filesystem/functions/fileinode.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.fileinode"> <refnamediv> <refname>fileinode</refname> @@ -40,6 +40,26 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Comparing the inode of a file with the current file</title> + <programlisting role="php"> +<![CDATA[ +<?php +$filename = 'index.php'; +if(getmyinode() == fileinode($filename)) +{ + echo('You are checking the current file.'); +} +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.clearstatcache; @@ -50,6 +70,7 @@ &reftitle.seealso; <para> <simplelist> + <member><function>getmyinode</function></member> <member><function>stat</function></member> </simplelist> </para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/fileowner.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/filesystem/functions/fileowner.xml diff -u phpdoc/en/reference/filesystem/functions/fileowner.xml:1.8 phpdoc/en/reference/filesystem/functions/fileowner.xml:1.9 --- phpdoc/en/reference/filesystem/functions/fileowner.xml:1.8 Wed Jun 20 22:24:27 2007 +++ phpdoc/en/reference/filesystem/functions/fileowner.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.fileowner"> <refnamediv> <refname>fileowner</refname> @@ -42,6 +42,23 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Finding the owner of a file</title> + <programlisting role="php"> +<![CDATA[ +<?php +$filename = 'index.php'; +print_r(posix_getpwuid(fileowner($filename))); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.clearstatcache; @@ -52,7 +69,9 @@ &reftitle.seealso; <para> <simplelist> + <member><function>filegroup</function></member> <member><function>stat</function></member> + <member><function>posix_getpwuid</function></member> </simplelist> </para> </refsect1> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/ftruncate.xml?r1=1.13&r2=1.14&diff_format=u Index: phpdoc/en/reference/filesystem/functions/ftruncate.xml diff -u phpdoc/en/reference/filesystem/functions/ftruncate.xml:1.13 phpdoc/en/reference/filesystem/functions/ftruncate.xml:1.14 --- phpdoc/en/reference/filesystem/functions/ftruncate.xml:1.13 Thu Jan 24 10:03:12 2008 +++ phpdoc/en/reference/filesystem/functions/ftruncate.xml Mon Oct 13 19:26:50 2008 @@ -1,11 +1,12 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.13 $ --> +<!-- $Revision: 1.14 $ --> <!-- splitted from ./en/functions/filesystem.xml, last change in rev 1.14 --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.ftruncate"> <refnamediv> <refname>ftruncate</refname> <refpurpose>Truncates a file to a given length</refpurpose> </refnamediv> + <refsect1 role="description"> &reftitle.description; <methodsynopsis> @@ -18,6 +19,7 @@ length, <parameter>size</parameter>. </para> </refsect1> + <refsect1 role="parameters"> &reftitle.parameters; <para> @@ -56,12 +58,14 @@ </variablelist> </para> </refsect1> + <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.success; </para> </refsect1> + <refsect1 role="changelog"> &reftitle.changelog; <para> @@ -87,6 +91,29 @@ </informaltable> </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>File truncation example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$filename = 'lorem_ipsum.txt'; + +$handle = fopen($filename, 'r+'); +ftruncate($handle, rand(1, filesize($filename))); +rewind($handle); +echo(fread($handle, filesize($filename))); +fclose($handle); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; <note> @@ -94,7 +121,8 @@ The file pointer is <emphasis>not</emphasis> changed. </para> </note> - </refsect1> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/lchgrp.xml?r1=1.5&r2=1.6&diff_format=u Index: phpdoc/en/reference/filesystem/functions/lchgrp.xml diff -u phpdoc/en/reference/filesystem/functions/lchgrp.xml:1.5 phpdoc/en/reference/filesystem/functions/lchgrp.xml:1.6 --- phpdoc/en/reference/filesystem/functions/lchgrp.xml:1.5 Wed May 28 04:42:06 2008 +++ phpdoc/en/reference/filesystem/functions/lchgrp.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.lchgrp"> <refnamediv> <refname>lchgrp</refname> @@ -55,6 +55,26 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Changing the group of a symbolic link</title> + <programlisting role="php"> +<![CDATA[ +<?php +$target = 'output.php'; +$link = 'output.html'; +symlink($target, $link); + +lchgroup($link, 8); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.no-remote; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/lchown.xml?r1=1.5&r2=1.6&diff_format=u Index: phpdoc/en/reference/filesystem/functions/lchown.xml diff -u phpdoc/en/reference/filesystem/functions/lchown.xml:1.5 phpdoc/en/reference/filesystem/functions/lchown.xml:1.6 --- phpdoc/en/reference/filesystem/functions/lchown.xml:1.5 Wed May 28 04:42:06 2008 +++ phpdoc/en/reference/filesystem/functions/lchown.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.lchown"> <refnamediv> <refname>lchown</refname> @@ -53,6 +53,26 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Changing the owner of a symbolic link</title> + <programlisting role="php"> +<![CDATA[ +<?php +$target = 'output.php'; +$link = 'output.html'; +symlink($target, $link); + +lchown($link, 8); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.no-remote; @@ -64,7 +84,7 @@ &reftitle.seealso; <para> <simplelist> - <member><function>chgrp</function></member> + <member><function>chown</function></member> <member><function>lchgrp</function></member> <member><function>chgrp</function></member> <member><function>chmod</function></member> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/link.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/filesystem/functions/link.xml diff -u phpdoc/en/reference/filesystem/functions/link.xml:1.10 phpdoc/en/reference/filesystem/functions/link.xml:1.11 --- phpdoc/en/reference/filesystem/functions/link.xml:1.10 Wed Jun 20 22:24:28 2007 +++ phpdoc/en/reference/filesystem/functions/link.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.link"> <refnamediv> <refname>link</refname> @@ -49,6 +49,26 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Creating a simple hard link</title> + <programlisting role="php"> +<![CDATA[ +<?php + +$source = "source.ext"; // This is the file that already exists +$dest = "newfile.ext"; // This the filename that you want to link it to + +link($source, $dest); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.no-remote; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/move-uploaded-file.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/filesystem/functions/move-uploaded-file.xml diff -u phpdoc/en/reference/filesystem/functions/move-uploaded-file.xml:1.7 phpdoc/en/reference/filesystem/functions/move-uploaded-file.xml:1.8 --- phpdoc/en/reference/filesystem/functions/move-uploaded-file.xml:1.7 Sat Sep 15 02:44:00 2007 +++ phpdoc/en/reference/filesystem/functions/move-uploaded-file.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.move-uploaded-file"> <refnamediv> <refname>move_uploaded_file</refname> @@ -68,6 +68,29 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Uploading multiple files</title> + <programlisting role="php"> +<![CDATA[ +<?php +$uploads_dir = '/uploads'; +foreach ($_FILES["pictures"]["error"] as $key => $error) { + if ($error == UPLOAD_ERR_OK) { + $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; + $name = $_FILES["pictures"]["name"][$key]; + move_uploaded_file($tmp_name, "$uploads_dir/$name"); + } +} +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; <note> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/pclose.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/filesystem/functions/pclose.xml diff -u phpdoc/en/reference/filesystem/functions/pclose.xml:1.7 phpdoc/en/reference/filesystem/functions/pclose.xml:1.8 --- phpdoc/en/reference/filesystem/functions/pclose.xml:1.7 Wed Jun 20 22:24:28 2007 +++ phpdoc/en/reference/filesystem/functions/pclose.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.pclose"> <refnamediv> <refname>pclose</refname> @@ -41,6 +41,23 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>pclose</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$handle = popen("/bin/ls", "r"); +pclose($handle); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/readfile.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/filesystem/functions/readfile.xml diff -u phpdoc/en/reference/filesystem/functions/readfile.xml:1.10 phpdoc/en/reference/filesystem/functions/readfile.xml:1.11 --- phpdoc/en/reference/filesystem/functions/readfile.xml:1.10 Sat Sep 15 02:44:00 2007 +++ phpdoc/en/reference/filesystem/functions/readfile.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.readfile"> <refnamediv> <refname>readfile</refname> @@ -62,6 +62,43 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Forcing a download using <function>readfile</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +$file = 'monkey.gif'; + +if(file_exists($file)) { + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename='.basename($file)); + header('Content-Transfer-Encoding: binary'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + header('Content-Length: ' . filesize($file)); + ob_clean(); + flush(); + readfile($file); + exit; +} +?> +]]> + </programlisting> + &example.outputs.similar; + <mediaobject> + <imageobject> + <imagedata fileref="figures/filesystem.readfile.png"/> + </imageobject> + </mediaobject> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/rewind.xml?r1=1.11&r2=1.12&diff_format=u Index: phpdoc/en/reference/filesystem/functions/rewind.xml diff -u phpdoc/en/reference/filesystem/functions/rewind.xml:1.11 phpdoc/en/reference/filesystem/functions/rewind.xml:1.12 --- phpdoc/en/reference/filesystem/functions/rewind.xml:1.11 Wed Jun 20 22:24:28 2007 +++ phpdoc/en/reference/filesystem/functions/rewind.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.11 $ --> +<!-- $Revision: 1.12 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.rewind"> <refnamediv> <refname>rewind</refname> @@ -49,12 +49,45 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>rewind</function> overwriting example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$handle = fopen('output.txt', 'r+'); + +fwrite($handle, 'Really long sentence.'); +rewind($handle); +fwrite($handle, 'Foo'); +rewind($handle); + +echo(fread($handle, filesize('output.txt'))); + +fclose($handle); +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +Foolly long sentence. +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> + <member><function>fread</function></member> <member><function>fseek</function></member> <member><function>ftell</function></member> + <member><function>fwrite</function></member> </simplelist> </para> </refsect1> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/rmdir.xml?r1=1.12&r2=1.13&diff_format=u Index: phpdoc/en/reference/filesystem/functions/rmdir.xml diff -u phpdoc/en/reference/filesystem/functions/rmdir.xml:1.12 phpdoc/en/reference/filesystem/functions/rmdir.xml:1.13 --- phpdoc/en/reference/filesystem/functions/rmdir.xml:1.12 Wed Jun 20 22:24:28 2007 +++ phpdoc/en/reference/filesystem/functions/rmdir.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.12 $ --> +<!-- $Revision: 1.13 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.rmdir"> <refnamediv> <refname>rmdir</refname> @@ -75,6 +75,27 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>rmdir</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +if(!is_dir('examples')) +{ + mkdir('examples'); +} + +rmdir('examples'); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.sm.uidcheck.dir; @@ -84,6 +105,7 @@ &reftitle.seealso; <para> <simplelist> + <member><function>is_dir</function></member> <member><function>mkdir</function></member> <member><function>unlink</function></member> </simplelist>
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/chgrp.xml?r1=1.9&r2=1.10&diff_format=u Index: phpdoc/en/reference/filesystem/functions/chgrp.xml diff -u phpdoc/en/reference/filesystem/functions/chgrp.xml:1.9 phpdoc/en/reference/filesystem/functions/chgrp.xml:1.10 --- phpdoc/en/reference/filesystem/functions/chgrp.xml:1.9 Wed Jun 20 22:24:27 2007 +++ phpdoc/en/reference/filesystem/functions/chgrp.xml Mon Oct 13 19:26:49 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.chgrp"> <refnamediv> <refname>chgrp</refname> @@ -54,6 +54,25 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Changing a file's group</title> + <programlisting role="php"> +<![CDATA[ +<?php +$filename = 'shared_file.txt'; +echo("$filename's Group ID @ " . time() . ": " . filegroup($filename) . "\n"); +chgrp($filename, 8); +echo("$filename's Group ID @ " . time() . ": " . filegroup($filename) . "\n"); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.no-remote; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/clearstatcache.xml?r1=1.13&r2=1.14&diff_format=u Index: phpdoc/en/reference/filesystem/functions/clearstatcache.xml diff -u phpdoc/en/reference/filesystem/functions/clearstatcache.xml:1.13 phpdoc/en/reference/filesystem/functions/clearstatcache.xml:1.14 --- phpdoc/en/reference/filesystem/functions/clearstatcache.xml:1.13 Thu Aug 16 15:48:12 2007 +++ phpdoc/en/reference/filesystem/functions/clearstatcache.xml Mon Oct 13 19:26:49 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.13 $ --> +<!-- $Revision: 1.14 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.clearstatcache"> <refnamediv> <refname>clearstatcache</refname> @@ -68,6 +68,45 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>clearstatcache</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$file = 'output_log.txt'; + +function get_owner($file) +{ + $stat = stat($file); + $user = posix_getpwuid($s['uid']); + return $user['name']; +} + +echo('UID @ ' . date('r') . ': ' . get_owner($file) . PHP_EOL); + +chown($path, 'ross'); +echo('UID @ ' . date('r') . ': ' . get_owner($file) . PHP_EOL); + +clearstatcache(); +echo('UID @ ' . date('r') . ': ' . get_owner($file) . PHP_EOL); +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +UID @ Sun, 12 Oct 2008 20:48:28 +0100: root +UID @ Sun, 12 Oct 2008 20:48:28 +0100: root +UID @ Sun, 12 Oct 2008 20:48:28 +0100: ross +]]> + </screen> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/fflush.xml?r1=1.9&r2=1.10&diff_format=u Index: phpdoc/en/reference/filesystem/functions/fflush.xml diff -u phpdoc/en/reference/filesystem/functions/fflush.xml:1.9 phpdoc/en/reference/filesystem/functions/fflush.xml:1.10 --- phpdoc/en/reference/filesystem/functions/fflush.xml:1.9 Wed Jun 20 22:24:27 2007 +++ phpdoc/en/reference/filesystem/functions/fflush.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.fflush"> <refnamediv> <refname>fflush</refname> @@ -39,6 +39,39 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>File write example using <function>fflush</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +$filename = 'bar.txt'; + +$file = fopen($filename, 'r+'); +rewind($file); +fwrite($file, 'Foo'); +fflush($file); +ftruncate($file, ftell($file)); +fclose($file); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>clearstatcache</function></member> + <member><function>fwrite</function></member> + </simplelist> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/fgetss.xml?r1=1.9&r2=1.10&diff_format=u Index: phpdoc/en/reference/filesystem/functions/fgetss.xml diff -u phpdoc/en/reference/filesystem/functions/fgetss.xml:1.9 phpdoc/en/reference/filesystem/functions/fgetss.xml:1.10 --- phpdoc/en/reference/filesystem/functions/fgetss.xml:1.9 Sun Jul 1 21:31:16 2007 +++ phpdoc/en/reference/filesystem/functions/fgetss.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.fgetss"> <refnamediv> <refname>fgetss</refname> @@ -94,6 +94,45 @@ </para> </refsect1> + <refsect1 role="examples"> + <para> + <example> + <title>Reading a PHP file line-by-line</title> + <programlisting role="php"> +<![CDATA[ +<?php +$str = <<<EOD +<html><body> + <p>Welcome! Today is the <?php echo(date('jS')); ?> of <?= date('F'); ?>.</p> +</body></html> +Text outside of the HTML block. +EOD; +file_put_contents('sample.php', $str); + +$handle = @fopen("sample.php", "r"); +if($handle) { + while(!feof($handle)) + { + $buffer = fgetss($handle, 4096); + echo $buffer; + } + fclose($handle); +} +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ + Welcome! Today is the of . + +Text outside of the HTML block. +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.line-endings; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/filegroup.xml?r1=1.9&r2=1.10&diff_format=u Index: phpdoc/en/reference/filesystem/functions/filegroup.xml diff -u phpdoc/en/reference/filesystem/functions/filegroup.xml:1.9 phpdoc/en/reference/filesystem/functions/filegroup.xml:1.10 --- phpdoc/en/reference/filesystem/functions/filegroup.xml:1.9 Wed Jun 20 22:24:27 2007 +++ phpdoc/en/reference/filesystem/functions/filegroup.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.filegroup"> <refnamediv> <refname>filegroup</refname> @@ -44,6 +44,23 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Finding the group of a file</title> + <programlisting role="php"> +<![CDATA[ +<?php +$filename = 'index.php'; +print_r(posix_getgrgid(filegroup($filename))); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="errors"> &reftitle.errors; <para> @@ -62,6 +79,7 @@ <para> <simplelist> <member><function>fileowner</function></member> + <member><function>posix_getgrgid</function></member> <member><link linkend="ini.safe-mode-gid">safe_mode_gid</link></member> </simplelist> </para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/fileinode.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/filesystem/functions/fileinode.xml diff -u phpdoc/en/reference/filesystem/functions/fileinode.xml:1.8 phpdoc/en/reference/filesystem/functions/fileinode.xml:1.9 --- phpdoc/en/reference/filesystem/functions/fileinode.xml:1.8 Wed Jun 20 22:24:27 2007 +++ phpdoc/en/reference/filesystem/functions/fileinode.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.fileinode"> <refnamediv> <refname>fileinode</refname> @@ -40,6 +40,26 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Comparing the inode of a file with the current file</title> + <programlisting role="php"> +<![CDATA[ +<?php +$filename = 'index.php'; +if(getmyinode() == fileinode($filename)) +{ + echo('You are checking the current file.'); +} +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.clearstatcache; @@ -50,6 +70,7 @@ &reftitle.seealso; <para> <simplelist> + <member><function>getmyinode</function></member> <member><function>stat</function></member> </simplelist> </para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/fileowner.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/filesystem/functions/fileowner.xml diff -u phpdoc/en/reference/filesystem/functions/fileowner.xml:1.8 phpdoc/en/reference/filesystem/functions/fileowner.xml:1.9 --- phpdoc/en/reference/filesystem/functions/fileowner.xml:1.8 Wed Jun 20 22:24:27 2007 +++ phpdoc/en/reference/filesystem/functions/fileowner.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.fileowner"> <refnamediv> <refname>fileowner</refname> @@ -42,6 +42,23 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Finding the owner of a file</title> + <programlisting role="php"> +<![CDATA[ +<?php +$filename = 'index.php'; +print_r(posix_getpwuid(fileowner($filename))); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.clearstatcache; @@ -52,7 +69,9 @@ &reftitle.seealso; <para> <simplelist> + <member><function>filegroup</function></member> <member><function>stat</function></member> + <member><function>posix_getpwuid</function></member> </simplelist> </para> </refsect1> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/ftruncate.xml?r1=1.13&r2=1.14&diff_format=u Index: phpdoc/en/reference/filesystem/functions/ftruncate.xml diff -u phpdoc/en/reference/filesystem/functions/ftruncate.xml:1.13 phpdoc/en/reference/filesystem/functions/ftruncate.xml:1.14 --- phpdoc/en/reference/filesystem/functions/ftruncate.xml:1.13 Thu Jan 24 10:03:12 2008 +++ phpdoc/en/reference/filesystem/functions/ftruncate.xml Mon Oct 13 19:26:50 2008 @@ -1,11 +1,12 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.13 $ --> +<!-- $Revision: 1.14 $ --> <!-- splitted from ./en/functions/filesystem.xml, last change in rev 1.14 --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.ftruncate"> <refnamediv> <refname>ftruncate</refname> <refpurpose>Truncates a file to a given length</refpurpose> </refnamediv> + <refsect1 role="description"> &reftitle.description; <methodsynopsis> @@ -18,6 +19,7 @@ length, <parameter>size</parameter>. </para> </refsect1> + <refsect1 role="parameters"> &reftitle.parameters; <para> @@ -56,12 +58,14 @@ </variablelist> </para> </refsect1> + <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.success; </para> </refsect1> + <refsect1 role="changelog"> &reftitle.changelog; <para> @@ -87,6 +91,29 @@ </informaltable> </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>File truncation example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$filename = 'lorem_ipsum.txt'; + +$handle = fopen($filename, 'r+'); +ftruncate($handle, rand(1, filesize($filename))); +rewind($handle); +echo(fread($handle, filesize($filename))); +fclose($handle); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; <note> @@ -94,7 +121,8 @@ The file pointer is <emphasis>not</emphasis> changed. </para> </note> - </refsect1> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/lchgrp.xml?r1=1.5&r2=1.6&diff_format=u Index: phpdoc/en/reference/filesystem/functions/lchgrp.xml diff -u phpdoc/en/reference/filesystem/functions/lchgrp.xml:1.5 phpdoc/en/reference/filesystem/functions/lchgrp.xml:1.6 --- phpdoc/en/reference/filesystem/functions/lchgrp.xml:1.5 Wed May 28 04:42:06 2008 +++ phpdoc/en/reference/filesystem/functions/lchgrp.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.lchgrp"> <refnamediv> <refname>lchgrp</refname> @@ -55,6 +55,26 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Changing the group of a symbolic link</title> + <programlisting role="php"> +<![CDATA[ +<?php +$target = 'output.php'; +$link = 'output.html'; +symlink($target, $link); + +lchgroup($link, 8); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.no-remote; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/lchown.xml?r1=1.5&r2=1.6&diff_format=u Index: phpdoc/en/reference/filesystem/functions/lchown.xml diff -u phpdoc/en/reference/filesystem/functions/lchown.xml:1.5 phpdoc/en/reference/filesystem/functions/lchown.xml:1.6 --- phpdoc/en/reference/filesystem/functions/lchown.xml:1.5 Wed May 28 04:42:06 2008 +++ phpdoc/en/reference/filesystem/functions/lchown.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.lchown"> <refnamediv> <refname>lchown</refname> @@ -53,6 +53,26 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Changing the owner of a symbolic link</title> + <programlisting role="php"> +<![CDATA[ +<?php +$target = 'output.php'; +$link = 'output.html'; +symlink($target, $link); + +lchown($link, 8); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.no-remote; @@ -64,7 +84,7 @@ &reftitle.seealso; <para> <simplelist> - <member><function>chgrp</function></member> + <member><function>chown</function></member> <member><function>lchgrp</function></member> <member><function>chgrp</function></member> <member><function>chmod</function></member> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/link.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/filesystem/functions/link.xml diff -u phpdoc/en/reference/filesystem/functions/link.xml:1.10 phpdoc/en/reference/filesystem/functions/link.xml:1.11 --- phpdoc/en/reference/filesystem/functions/link.xml:1.10 Wed Jun 20 22:24:28 2007 +++ phpdoc/en/reference/filesystem/functions/link.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.link"> <refnamediv> <refname>link</refname> @@ -49,6 +49,26 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Creating a simple hard link</title> + <programlisting role="php"> +<![CDATA[ +<?php + +$source = "source.ext"; // This is the file that already exists +$dest = "newfile.ext"; // This the filename that you want to link it to + +link($source, $dest); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.no-remote; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/move-uploaded-file.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/filesystem/functions/move-uploaded-file.xml diff -u phpdoc/en/reference/filesystem/functions/move-uploaded-file.xml:1.7 phpdoc/en/reference/filesystem/functions/move-uploaded-file.xml:1.8 --- phpdoc/en/reference/filesystem/functions/move-uploaded-file.xml:1.7 Sat Sep 15 02:44:00 2007 +++ phpdoc/en/reference/filesystem/functions/move-uploaded-file.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.move-uploaded-file"> <refnamediv> <refname>move_uploaded_file</refname> @@ -68,6 +68,29 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Uploading multiple files</title> + <programlisting role="php"> +<![CDATA[ +<?php +$uploads_dir = '/uploads'; +foreach ($_FILES["pictures"]["error"] as $key => $error) { + if ($error == UPLOAD_ERR_OK) { + $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; + $name = $_FILES["pictures"]["name"][$key]; + move_uploaded_file($tmp_name, "$uploads_dir/$name"); + } +} +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; <note> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/pclose.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/filesystem/functions/pclose.xml diff -u phpdoc/en/reference/filesystem/functions/pclose.xml:1.7 phpdoc/en/reference/filesystem/functions/pclose.xml:1.8 --- phpdoc/en/reference/filesystem/functions/pclose.xml:1.7 Wed Jun 20 22:24:28 2007 +++ phpdoc/en/reference/filesystem/functions/pclose.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.pclose"> <refnamediv> <refname>pclose</refname> @@ -41,6 +41,23 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>pclose</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$handle = popen("/bin/ls", "r"); +pclose($handle); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/readfile.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/filesystem/functions/readfile.xml diff -u phpdoc/en/reference/filesystem/functions/readfile.xml:1.10 phpdoc/en/reference/filesystem/functions/readfile.xml:1.11 --- phpdoc/en/reference/filesystem/functions/readfile.xml:1.10 Sat Sep 15 02:44:00 2007 +++ phpdoc/en/reference/filesystem/functions/readfile.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.readfile"> <refnamediv> <refname>readfile</refname> @@ -62,6 +62,43 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Forcing a download using <function>readfile</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +$file = 'monkey.gif'; + +if(file_exists($file)) { + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename='.basename($file)); + header('Content-Transfer-Encoding: binary'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + header('Content-Length: ' . filesize($file)); + ob_clean(); + flush(); + readfile($file); + exit; +} +?> +]]> + </programlisting> + &example.outputs.similar; + <mediaobject> + <imageobject> + <imagedata fileref="figures/filesystem.readfile.png"/> + </imageobject> + </mediaobject> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/rewind.xml?r1=1.11&r2=1.12&diff_format=u Index: phpdoc/en/reference/filesystem/functions/rewind.xml diff -u phpdoc/en/reference/filesystem/functions/rewind.xml:1.11 phpdoc/en/reference/filesystem/functions/rewind.xml:1.12 --- phpdoc/en/reference/filesystem/functions/rewind.xml:1.11 Wed Jun 20 22:24:28 2007 +++ phpdoc/en/reference/filesystem/functions/rewind.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.11 $ --> +<!-- $Revision: 1.12 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.rewind"> <refnamediv> <refname>rewind</refname> @@ -49,12 +49,45 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>rewind</function> overwriting example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$handle = fopen('output.txt', 'r+'); + +fwrite($handle, 'Really long sentence.'); +rewind($handle); +fwrite($handle, 'Foo'); +rewind($handle); + +echo(fread($handle, filesize('output.txt'))); + +fclose($handle); +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +Foolly long sentence. +]]> + </screen> + </example> + </para> + </refsect1> + <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> + <member><function>fread</function></member> <member><function>fseek</function></member> <member><function>ftell</function></member> + <member><function>fwrite</function></member> </simplelist> </para> </refsect1> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/rmdir.xml?r1=1.12&r2=1.13&diff_format=u Index: phpdoc/en/reference/filesystem/functions/rmdir.xml diff -u phpdoc/en/reference/filesystem/functions/rmdir.xml:1.12 phpdoc/en/reference/filesystem/functions/rmdir.xml:1.13 --- phpdoc/en/reference/filesystem/functions/rmdir.xml:1.12 Wed Jun 20 22:24:28 2007 +++ phpdoc/en/reference/filesystem/functions/rmdir.xml Mon Oct 13 19:26:50 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.12 $ --> +<!-- $Revision: 1.13 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.rmdir"> <refnamediv> <refname>rmdir</refname> @@ -75,6 +75,27 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>rmdir</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +if(!is_dir('examples')) +{ + mkdir('examples'); +} + +rmdir('examples'); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; ¬e.sm.uidcheck.dir; @@ -84,6 +105,7 @@ &reftitle.seealso; <para> <simplelist> + <member><function>is_dir</function></member> <member><function>mkdir</function></member> <member><function>unlink</function></member> </simplelist>