[prev in list] [next in list] [prev in thread] [next in thread]
List: php-doc-cvs
Subject: Re: [DOC-CVS] cvs: phpdoc /en/reference/filesystem/functions stat.xml touch.xml
From: "Hannes Magnusson" <hannes.magnusson () gmail ! com>
Date: 2008-08-31 9:16:36
Message-ID: 7f3ed2c30808310216h45ccaba1v133fd11727c43424 () mail ! gmail ! com
[Download RAW message or body]
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
--
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic