For some questions about strtok in php, please refer to the following code PHPcode & lt ;? Php $ string & quot; Helloworld. Beautifuldaytoday. & quot; $ tokenstrtok ($ string, & quot;); while ($ token! False) {echo & quot; $ t some questions about strtok in php
See the following code
PHP code
"; $token = strtok(" "); } ?>
The condition for loop termination should be $ token = false, but strtok returns a value of the string type. how can the two be =?
It is known that ''= false is not true, that is, $ token ='' is also not true. what is the final value of $ token?
------ Solution --------------------
Php is a weak language. let's look at this example.
$ Str = '';
$ Token = strtok ($ str ,'');
Var_dump ($ token );
Bool (false) is returned at this time)
Have you seen it? So it is used! = FALSE;
------ Solution --------------------
Under normal circumstances, strtok does return a string, but it does not exist after finding the last one. at this time, the return value is not a string or NULL, but a boolean value of false, which is specified by the person who writes this function.