From d225d8999548421ae145c612f14c683a41e543f9 Mon Sep 17 00:00:00 2001 From: Christoph Michael Becker Date: Wed, 14 Sep 2016 11:53:33 +0000 Subject: [PATCH] Update manual wrt. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@340032 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/types/string.xml | 11 ++++- .../functions/file-get-contents.xml | 7 ++++ reference/iconv/functions/iconv-strpos.xml | 23 ++++++++++ reference/intl/grapheme/grapheme-extract.xml | 25 ++++++++++- reference/intl/grapheme/grapheme-stripos.xml | 23 ++++++++++ reference/intl/grapheme/grapheme-strpos.xml | 25 ++++++++++- .../functions/mb-ereg-search-setpos.xml | 24 ++++++++++- .../mbstring/functions/mb-strimwidth.xml | 27 +++++++++++- reference/mbstring/functions/mb-stripos.xml | 42 +++++++++---------- reference/mbstring/functions/mb-strpos.xml | 23 ++++++++++ reference/strings/functions/stripos.xml | 26 +++++++++++- reference/strings/functions/strpos.xml | 26 +++++++++++- reference/strings/functions/substr-count.xml | 10 ++++- 13 files changed, 259 insertions(+), 33 deletions(-) diff --git a/language/types/string.xml b/language/types/string.xml index 0e0bee0a25..73af7c23b4 100644 --- a/language/types/string.xml +++ b/language/types/string.xml @@ -745,6 +745,16 @@ echo "I'd like an {${beers::$ale}}\n"; substr and substr_replace can be used when you want to extract or replace more than 1 character. + + + + 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 E_NOTICE for reading + (yielding an empty string) and E_WARNING for writing + (leaving the string untouched). + + @@ -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 E_NOTICE. - Negative offset emits E_NOTICE 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. diff --git a/reference/filesystem/functions/file-get-contents.xml b/reference/filesystem/functions/file-get-contents.xml index 673361e7e1..c1384b370f 100644 --- a/reference/filesystem/functions/file-get-contents.xml +++ b/reference/filesystem/functions/file-get-contents.xml @@ -75,6 +75,7 @@ The offset where the reading starts on the original stream. + Negative offsets count from the end of the stream. Seeking (offset) is not supported with remote files. @@ -195,6 +196,12 @@ $file = file_get_contents('http://www.example.com/', false, $context); + + 7.1.0 + + Support for negative offsets has been added. + + 5.1.0 diff --git a/reference/iconv/functions/iconv-strpos.xml b/reference/iconv/functions/iconv-strpos.xml index f3aed424bb..f97b5b47c4 100644 --- a/reference/iconv/functions/iconv-strpos.xml +++ b/reference/iconv/functions/iconv-strpos.xml @@ -54,6 +54,7 @@ The optional offset 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. @@ -89,6 +90,28 @@ &return.falseproblem; + + &reftitle.changelog; + + + + + &Version; + &Description; + + + + + 7.1.0 + + Support for negative offsets has been added. + + + + + + + &reftitle.seealso; diff --git a/reference/intl/grapheme/grapheme-extract.xml b/reference/intl/grapheme/grapheme-extract.xml index 0c55e078c1..b59da102fb 100644 --- a/reference/intl/grapheme/grapheme-extract.xml +++ b/reference/intl/grapheme/grapheme-extract.xml @@ -65,7 +65,8 @@ 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. @@ -93,6 +94,28 @@ + + &reftitle.changelog; + + + + + &Version; + &Description; + + + + + 7.1.0 + + Support for negative starts has been added. + + + + + + + &reftitle.examples; diff --git a/reference/intl/grapheme/grapheme-stripos.xml b/reference/intl/grapheme/grapheme-stripos.xml index fc55218c48..cced218bf5 100644 --- a/reference/intl/grapheme/grapheme-stripos.xml +++ b/reference/intl/grapheme/grapheme-stripos.xml @@ -45,6 +45,7 @@ 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. @@ -62,6 +63,28 @@ + + &reftitle.changelog; + + + + + &Version; + &Description; + + + + + 7.1.0 + + Support for negative offsets has been added. + + + + + + + &reftitle.examples; diff --git a/reference/intl/grapheme/grapheme-strpos.xml b/reference/intl/grapheme/grapheme-strpos.xml index 0b15d11879..04b607ad3e 100644 --- a/reference/intl/grapheme/grapheme-strpos.xml +++ b/reference/intl/grapheme/grapheme-strpos.xml @@ -45,6 +45,7 @@ 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. @@ -58,10 +59,32 @@ &reftitle.returnvalues; - 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. + + &reftitle.changelog; + + + + + &Version; + &Description; + + + + + 7.1.0 + + Support for negative offsets has been added. + + + + + + + &reftitle.examples; diff --git a/reference/mbstring/functions/mb-ereg-search-setpos.xml b/reference/mbstring/functions/mb-ereg-search-setpos.xml index 5b8dbd1719..58a46dac55 100644 --- a/reference/mbstring/functions/mb-ereg-search-setpos.xml +++ b/reference/mbstring/functions/mb-ereg-search-setpos.xml @@ -26,7 +26,7 @@ position - The position to set. + The position to set. If it is negative, it counts from the end of the string. @@ -41,6 +41,28 @@ + + &reftitle.changelog; + + + + + &Version; + &Description; + + + + + 7.1.0 + + Support for negative positions has been added. + + + + + + + &reftitle.notes; diff --git a/reference/mbstring/functions/mb-strimwidth.xml b/reference/mbstring/functions/mb-strimwidth.xml index 38ab4ec755..e13f836dab 100644 --- a/reference/mbstring/functions/mb-strimwidth.xml +++ b/reference/mbstring/functions/mb-strimwidth.xml @@ -38,7 +38,8 @@ 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. @@ -46,7 +47,7 @@ width - The width of the desired trim. + The width of the desired trim. Negative widths count from the end of the string. @@ -77,6 +78,28 @@ + + &reftitle.changelog; + + + + + &Version; + &Description; + + + + + 7.1.0 + + Support for negative starts and widths has been added. + + + + + + + &reftitle.examples; diff --git a/reference/mbstring/functions/mb-stripos.xml b/reference/mbstring/functions/mb-stripos.xml index c4d345406d..3b7d047537 100644 --- a/reference/mbstring/functions/mb-stripos.xml +++ b/reference/mbstring/functions/mb-stripos.xml @@ -50,7 +50,8 @@ The position in haystack - to start searching + to start searching. + A negative offset counts from the end of the string. @@ -75,30 +76,27 @@ - -