cvs: phpdoc /en/language types.xml

From: Date: Sun, 09 Jun 2002 19:52:00 +0000
Subject: cvs: phpdoc /en/language types.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969346302@lists.php.net to get a copy of this message
mfischer Sun Jun 9 15:52:00 2002 EDT Modified files: /phpdoc/en/language types.xml Log: - Explain more behaviours of using certain kind of keys for arrays. - Removed note about negative array keys. # Can someone explain me why there was an note about better not documented # negative array indices? Explain me what's wrong not documented it, if you've # good reason I will reconsider the removement. And the note was bogus too (IMHO). Index: phpdoc/en/language/types.xml diff -u phpdoc/en/language/types.xml:1.82 phpdoc/en/language/types.xml:1.83 --- phpdoc/en/language/types.xml:1.82 Sun May 26 11:50:03 2002 +++ phpdoc/en/language/types.xml Sun Jun 9 15:52:00 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.82 $ --> +<!-- $Revision: 1.83 $ --> <chapter id="language.types"> <title>Types</title> @@ -1075,40 +1075,38 @@ pairs. </para> <para> - A <varname>key</varname> is either a nonnegative <type>integer</type> - <!-- - - Negative integers are also allowed, however, IMO it's best to not - document that, or even disencourage it. - - Why? - - First, because it is very tricky. But the real reason is that the key - '-1' will be interpreted as a string, and not as a integer. Therefore, - the usage - - "the -1'st value of \$arr is $arr[-1]" is ambigious. By the way, - it results in a parse-error anyway, which is another argument for - not documenting it. - - -Jeroen - - --> + A <varname>key</varname> is either an <type>integer</type> or a <type>string</type>. - If a key is the standard representation of a non-negative + If a key is the standard representation of an <type>integer</type>, it will - be interpreted as such (i.e. <literal>'8'</literal> will be interpreted + be interpreted as such (i.e. <literal>"8"</literal> will be interpreted as <literal>8</literal>, while - <literal>'08'</literal> will be interpreted as <literal>'08'</literal>). + <literal>"08"</literal> will be interpreted as <literal>"08"</literal>). </para> <para> A value can be anything. </para> <para> If you omit a key, the maximum of the integer-indices is taken, and - the new key will be that maximum + 1. If no integer-indices exist + the new key will be that maximum + 1. As integers can be negative, + this is also true for negative indices. Having e.g. the highest index + being <literal>-6</literal> will result in being <literal>-5</literal> + the new key. If no integer-indices exist yet, the key will be <literal>0</literal> (zero). If you specify a key that already has a value assigned to it, that value will be overwritten. + </para> + <para> + Using <literal>true</literal> as a key will evalute to + <type>integer</type> <literal>1</literal> as key. Using + <literal>false</literal> as a key will evalute to <type>integer</type> + <literal>0</literal> as key. Using <literal>NULL</literal> as a key + will evalute to an empty string. Using an emptry string as key will + create (or overwrite) a key with an empty string and its value, it is + not the same as using empty brackets. + </para> + <para> + You cannot use arrays or objects as keys. Doing so will result in a + warning: <literal>Illegal offset type</literal>. </para> <para>

« previous php.doc (#969346302) next »