- Added changed strtok behavior to the manual

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@65267 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Derick Rethans 2001-12-16 10:34:01 +00:00
parent d4a1917f42
commit 25e51e3e37

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.139 $ -->
<!-- $Revision: 1.140 $ -->
<reference id="ref.strings">
<title>String functions</title>
<titleabbrev>Strings</titleabbrev>
@ -3425,6 +3425,41 @@ while ($tok) {
tokenized when any one of the characters in the argument are
found.
</para>
<para>
The behavior when an empty part was found changed with PHP 4.1.0. The old
behavior returned an empty string, while the new, correct, behavior
simply skips the part of the string:
<example>
<title>Old <function>strtok</function> behavior</title>
<programlisting role="php">
<![CDATA[
$first_token = strtok('/something', '/');
$second_token = strtok('/');
var_dump ($first_token, $second_token);
/* Output:
string(0) ""
string(9) "something"
*/
]]>
</programlisting>
</example>
<example>
<title>New <function>strtok</function> behavior</title>
<programlisting role="php">
<![CDATA[
$first_token = strtok('/something', '/');
$second_token = strtok('/');
var_dump ($first_token, $second_token);
/* Output:
string(9) "something"
bool(false)
*/
]]>
</programlisting>
</example>
</para>
<para>
Also be careful that your tokens may be equal to "0". This
evaluates to &false; in conditional expressions.