git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@340032 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Christoph Michael Becker 2016-09-14 11:53:33 +00:00
parent 68199788a9
commit d225d89995
13 changed files with 259 additions and 33 deletions

View file

@ -745,6 +745,16 @@ echo "I'd like an {${beers::$ale}}\n";
<function>substr</function> and <function>substr_replace</function>
can be used when you want to extract or replace more than 1 character.
</para>
<note>
<simpara>
As of PHP 7.1.0, negative string offsets are also supported. These specify
the offset from the end of the string.
Formerly, negative offsets emitted <constant>E_NOTICE</constant> for reading
(yielding an empty string) and <constant>E_WARNING</constant> for writing
(leaving the string untouched).
</simpara>
</note>
<note>
<simpara>
@ -758,7 +768,6 @@ echo "I'd like an {${beers::$ale}}\n";
Writing to an out of range offset pads the string with spaces.
Non-integer types are converted to integer.
Illegal offset type emits <constant>E_NOTICE</constant>.
Negative offset emits <constant>E_NOTICE</constant> in write but reads empty string.
Only the first character of an assigned string is used.
As of PHP 7.1.0, assigning an empty string throws a fatal error. Formerly,
it assigned a NULL byte.

View file

@ -75,6 +75,7 @@
<listitem>
<para>
The offset where the reading starts on the original stream.
Negative offsets count from the end of the stream.
</para>
<para>
Seeking (<parameter>offset</parameter>) is not supported with remote files.
@ -195,6 +196,12 @@ $file = file_get_contents('http://www.example.com/', false, $context);
</row>
</thead>
<tbody>
<row>
<entry>7.1.0</entry>
<entry>
Support for negative <parameter>offset</parameter>s has been added.
</entry>
</row>
<row>
<entry>5.1.0</entry>
<entry>

View file

@ -54,6 +54,7 @@
<para>
The optional <parameter>offset</parameter> parameter specifies
the position from which the search should be performed.
If the offset is negative, it is counted from the end of the string.
</para>
</listitem>
</varlistentry>
@ -89,6 +90,28 @@
&return.falseproblem;
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>7.1.0</entry>
<entry>
Support for negative <parameter>offset</parameter>s has been added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>

View file

@ -65,7 +65,8 @@
<para>
Starting position in $haystack in bytes - if given, it must be zero or a
positive value that is less than or equal to the length of $haystack in
bytes. If $start does not point to the first byte of a UTF-8
bytes, or a negative value that counts from the end of $haystack.
If $start does not point to the first byte of a UTF-8
character, the start position is moved to the next character boundary.
</para>
</listitem>
@ -93,6 +94,28 @@
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>7.1.0</entry>
<entry>
Support for negative <parameter>start</parameter>s has been added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>

View file

@ -45,6 +45,7 @@
<para>
The optional $offset parameter allows you to specify where in haystack to
start searching as an offset in grapheme units (not bytes or characters).
If the offset is negative, it is treated relative to the end of the string.
The position returned is still relative to the beginning of haystack
regardless of the value of $offset.
</para>
@ -62,6 +63,28 @@
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>7.1.0</entry>
<entry>
Support for negative <parameter>offset</parameter>s has been added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>

View file

@ -45,6 +45,7 @@
<para>
The optional $offset parameter allows you to specify where in $haystack to
start searching as an offset in grapheme units (not bytes or characters).
If the offset is negative, it is treated relative to the end of the string.
The position returned is still relative to the beginning of haystack
regardless of the value of $offset.
</para>
@ -58,10 +59,32 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the position as an integer. If needle is not found, strpos() will return boolean FALSE.
Returns the position as an integer. If needle is not found, grapheme_strpos() will return boolean FALSE.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>7.1.0</entry>
<entry>
Support for negative <parameter>offset</parameter>s has been added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>

View file

@ -26,7 +26,7 @@
<term><parameter>position</parameter></term>
<listitem>
<para>
The position to set.
The position to set. If it is negative, it counts from the end of the string.
</para>
</listitem>
</varlistentry>
@ -41,6 +41,28 @@
</simpara>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>7.1.0</entry>
<entry>
Support for negative <parameter>position</parameter>s has been added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;

View file

@ -38,7 +38,8 @@
<listitem>
<para>
The start position offset. Number of
characters from the beginning of string. (First character is 0)
characters from the beginning of string (first character is 0),
or if start is negative, number of characters from the end of the string.
</para>
</listitem>
</varlistentry>
@ -46,7 +47,7 @@
<term><parameter>width</parameter></term>
<listitem>
<para>
The width of the desired trim.
The width of the desired trim. Negative widths count from the end of the string.
</para>
</listitem>
</varlistentry>
@ -77,6 +78,28 @@
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>7.1.0</entry>
<entry>
Support for negative <parameter>start</parameter>s and <parameter>width</parameter>s has been added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>

View file

@ -50,7 +50,8 @@
<listitem>
<para>
The position in <parameter>haystack</parameter>
to start searching
to start searching.
A negative offset counts from the end of the string.
</para>
</listitem>
</varlistentry>
@ -75,30 +76,27 @@
</para>
</refsect1>
<!-- Use when a CHANGELOG exists
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>Enter the PHP version of change here</entry>
<entry>Description of change</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>7.1.0</entry>
<entry>
Support for negative <parameter>offset</parameter>s has been added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
-->
<!-- Use when examples exist
<refsect1 role="examples">

View file

@ -53,6 +53,7 @@
<listitem>
<para>
The search offset. If it is not specified, 0 is used.
A negative offset counts from the end of the string.
</para>
</listitem>
</varlistentry>
@ -76,6 +77,28 @@
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>7.1.0</entry>
<entry>
Support for negative <parameter>offset</parameter>s has been added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>

View file

@ -54,8 +54,8 @@
<listitem>
<para>
If specified, search will start this number of characters counted from
the beginning of the string. Unlike <function>strrpos</function> and
<function>strripos</function>, the offset cannot be negative.
the beginning of the string. If the offset is negative, the search will start
this number of characters counted from the end of the string.
</para>
</listitem>
</varlistentry>
@ -76,6 +76,28 @@
&return.falseproblem;
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>7.1.0</entry>
<entry>
Support for negative <parameter>offset</parameter>s has been added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>

View file

@ -46,8 +46,8 @@
<listitem>
<para>
If specified, search will start this number of characters counted from
the beginning of the string. Unlike <function>strrpos</function> and
<function>strripos</function>, the offset cannot be negative.
the beginning of the string. If the offset is negative, the search will start
this number of characters counted from the end of the string.
</para>
</listitem>
</varlistentry>
@ -68,6 +68,28 @@
&return.falseproblem;
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>7.1.0</entry>
<entry>
Support for negative <parameter>offset</parameter>s has been added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>

View file

@ -52,7 +52,8 @@
<term><parameter>offset</parameter></term>
<listitem>
<para>
The offset where to start counting
The offset where to start counting. If the offset is negative, counting
starts from the end of the string.
</para>
</listitem>
</varlistentry>
@ -63,6 +64,7 @@
The maximum length after the specified offset to search for the
substring. It outputs a warning if the offset plus the length is
greater than the <parameter>haystack</parameter> length.
A negative length counts from the end of <parameter>haystack</parameter>.
</para>
</listitem>
</varlistentry>
@ -89,6 +91,12 @@
</row>
</thead>
<tbody>
<row>
<entry>7.1.0</entry>
<entry>
Support for negative <parameter>offset</parameter>s and <parameter>length</parameter>s has been added.
</entry>
</row>
<row>
<entry>5.1.0</entry>
<entry>