For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > August 2006 > Re: [PHP-DOC] cvs: phpdoc /en/language types.xml









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DOC] cvs: phpdoc /en/language types.xml
Nuno Lopes

2006-08-31, 6:57 pm

Hello, I'm back :)

I don't think the $a{1} style is deprecated.. I don't really remember of
that decision on the internals mailing list. The E_STRICT warning was even
removed.
I think we need to double-check this one.

Nuno


----- Original Message -----
> philip Thu Aug 31 01:57:26 2006 UTC
>
> Modified files:
> /phpdoc/en/language types.xml
> Log:
> $string{42} is indeed deprecated as of PHP 6, so let's document that.
> Also, removed "string offset" information from the "type juggling"
> section.
> This also closes bug #38645
>
>
> http://cvs.php.net/viewvc.cgi/phpdo...7&diff_format=u
> Index: phpdoc/en/language/types.xml
> diff -u phpdoc/en/language/types.xml:1.166
> phpdoc/en/language/types.xml:1.167
> --- phpdoc/en/language/types.xml:1.166 Thu May 4 02:21:28 2006
> +++ phpdoc/en/language/types.xml Thu Aug 31 01:57:26 2006
> @@ -1,5 +1,5 @@
> <?xml version="1.0" encoding="iso-8859-1"?>
> -<!-- $Revision: 1.166 $ -->
> +<!-- $Revision: 1.167 $ -->
> <chapter id="language.types">
> <title>Types</title>
>
> @@ -1090,7 +1090,8 @@
> <note>
> <simpara>
> They may also be accessed using braces like
> <varname>$str{42}</varname>
> - for the same purpose. However, using square array-brackets is
> preferred.
> + for the same purpose. However, using square array-brackets is
> preferred
> + because the {braces} style is deprecated as of PHP 6.
> </simpara>
> </note>
> <para>
> @@ -1114,7 +1115,7 @@
> $str = 'Look at the sea';
> $str[strlen($str)-1] = 'e';
>
> -// Alternative method using {}
> +// Alternative method using {} is deprecated as of PHP 6
> $third = $str{2};
>
> ?>
> @@ -2446,41 +2447,22 @@
> undefined.
> </para>
> <para>
> + Also, because PHP supports indexing into strings via offsets using
> + the same syntax as array indexing, the following example holds true
> + for all PHP versions:
> <informalexample>
> <programlisting role="php">
> <![CDATA[
> <?php
> -$a = "1"; // $a is a string
> -$a[0] = "f"; // What about string offsets? What happens?
> +$a = 'car'; // $a is a string
> +$a[0] = 'b'; // $a is still a string
> +echo $a; // bar
> ?>
> ]]>
> </programlisting>
> </informalexample>
> </para>
> <para>
> - Since PHP (for historical reasons) supports indexing into strings
> - via offsets using the same syntax as array indexing, the example
> - above leads to a problem: should $a become an array with its first
> - element being "f", or should "f" become the first character of the
> - string $a?
> - </para>
> - <para>
> - The current versions of PHP interpret the second assignment as
> - a string offset identification, so $a becomes "f", the result
> - of this automatic conversion however should be considered
> - undefined. PHP 4 introduced the new curly bracket syntax to access
> - characters in string, use this syntax instead of the one presented
> - above:
> - <informalexample>
> - <programlisting role="php">
> -<![CDATA[
> -<?php
> -$a = "abc"; // $a is a string
> -$a{1} = "f"; // $a is now "afc"
> -?>
> -]]>
> - </programlisting>
> - </informalexample>
> See the section titled <link
> linkend="language.types.string.substr">String
> access by character</link> for more information.
> </para>
>

Philip Olson

2006-08-31, 6:57 pm


> Hello, I'm back :)


Good, welcome back! :)

> I don't think the $a{1} style is deprecated.. I don't really
> remember of that decision on the internals mailing list. The
> E_STRICT warning was even removed.
> I think we need to double-check this one.
>


We discussed it on IRC yesterday and the internals team still feels
it's deprecated as of PHP 6. Due to the enormous number of emails/
discussion/war the last internals discussion generated on this, few
want to discuss it further (or ever again!), but it's generally
considered deprecated despite not producing the E_ level error (yet?).

Regards,
Philip
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com