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

From: Date: Sun, 31 Aug 2008 09:16:36 +0000
Subject: Re: cvs: phpdoc /en/reference/filesystem/functions stat.xml touch.xml
References: 1  Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-2124@lists.php.net to get a copy of this message
2008/8/31 Kalle Sommer Nielsen <kalle@php.net>: > 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...'); > +} IIRC the "examples, best practice" says not to use die()/exit() statements. > + > +/* > + * 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'); > +} And this is definitely not something examples should have. The timezone should be set via php.ini anyway. > + > +/* We want the access time to be 1 week ago */ > +$atime = $stat['atime'] + 604800; This isn't necessarily one week ago.... -Hannes

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