cvs: phpdoc /en/reference/filesystem/functions stat.xml touch.xml

From: Date: Sun, 31 Aug 2008 01:30:39 +0000
Subject: cvs: phpdoc /en/reference/filesystem/functions stat.xml touch.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-2123@lists.php.net to get a copy of this message
kalle Sun Aug 31 01:30:39 2008 UTC Modified files: /phpdoc/en/reference/filesystem/functions stat.xml touch.xml Log: Added new example for touch() Added two examples for stat() http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/stat.xml?r1=1.22&r2=1.23&diff_format=u Index: phpdoc/en/reference/filesystem/functions/stat.xml diff -u phpdoc/en/reference/filesystem/functions/stat.xml:1.22 phpdoc/en/reference/filesystem/functions/stat.xml:1.23 --- phpdoc/en/reference/filesystem/functions/stat.xml:1.22 Mon Aug 25 04:22:37 2008 +++ phpdoc/en/reference/filesystem/functions/stat.xml Sun Aug 31 01:30:39 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.22 $ --> +<!-- $Revision: 1.23 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.stat"> <refnamediv> <refname>stat</refname> @@ -166,6 +166,77 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>stat</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +/* Get file stat */ +$stat = stat('C:\php\php.exe'); + +/* + * Print file access file, this is the same + * as calling fileatime() + */ +echo 'Access time: ' . $stat['atime']; + +/* + * Print file modification time, this is the + * same as calling filemtime() + */ +echo 'Modification time: ' . $stat['mtime']; + +/* Print the device number */ +echo 'Device number: ' . $stat['dev']; +]]> + </programlisting> + </example> + </para> + <para> + <example> + <title>Using <function>stat</function> information together with <function>touch</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +/* Get file stat */ +$stat = @stat('C:\php\php.exe'); + +/* Did we failed to get stat information ? */ +if(!$stat) +{ + die('Stat call failed, aborting...'); +} + +/* + * Like in the example for touch() we'll need to + * set the timezone to prevent E_STRICT errors in + * PHP 5.1+ + */ +if(function_exists('date_default_timezone_set')) +{ + date_default_timezone_set('UTC'); +} + +/* We want the access time to be 1 week ago */ +$atime = $stat['atime'] + 604800; + +/* Touch the file */ +if(!@touch('some_file.txt', time(), $atime)) +{ + die('Failed to touch file...'); +} + +echo 'Touch returned success...'; +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + <refsect1 role="notes"> &reftitle.notes; &note.filesystem-time-res; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/touch.xml?r1=1.18&r2=1.19&diff_format=u Index: phpdoc/en/reference/filesystem/functions/touch.xml diff -u phpdoc/en/reference/filesystem/functions/touch.xml:1.18 phpdoc/en/reference/filesystem/functions/touch.xml:1.19 --- phpdoc/en/reference/filesystem/functions/touch.xml:1.18 Mon Aug 25 04:22:37 2008 +++ phpdoc/en/reference/filesystem/functions/touch.xml Sun Aug 31 01:30:39 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.18 $ --> +<!-- $Revision: 1.19 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.touch"> <refnamediv> <refname>touch</refname> @@ -110,6 +110,39 @@ </programlisting> </example> </para> + <para> + <example> + <title><function>touch</function> using the <parameter>time</parameter> parameter</title> + <programlisting role="php"> +<![CDATA[ +<?php +/* + * First set the time zone if PHP 5.1+, this will + * prevent any E_STRICT errors. + */ +if(function_exists('date_default_timezone_set')) +{ + date_default_timezone_set('UTC'); +} + +/* + * Next is the touch time, we'll set it to one hour + * in the past. + */ +$time = time() - 3600; + +/* Touch the file */ +if(!touch('some_file.txt', $time)) +{ + die('Whoops, something went wrong...'); +} + +echo 'Touched file with success'; +?> +]]> + </programlisting> + </example> + </para> </refsect1> <refsect1 role="notes">

« previous php.doc.cvs (#2123) next »