This article illustrates the way PHP judges the beginning and end of a string. Share to everyone for your reference, specific as follows:
Variable:
$s 1 = "Dotcoo world!";
$s 2 = "dotcoo";
$s 3 = "Hello Dotcoo";
PHP judgment string Start:
var_dump (substr ($s 1, 0, strlen ($s 2)) = = = $s 2);
Var_dump (Strpos ($s 1, $s 2) = 0);
Var_dump (strncmp ($s 1, $s 2, strlen ($s 2)) = = 0);
Var_dump (Substr_compare ($s 1, $s 2, 0, strlen ($s 2)) = = 0);
End of PHP judgment string:
var_dump (substr ($s 1, 0, strlen ($s 2)) = = = $s 2);
Var_dump (Substr_compare ($s 3, $s 2,-strlen ($s 2)) = = 0);
For more information about PHP interested readers can view the site topics: "PHP string (String) Usage summary", "PHP array Operation techniques Encyclopedia", "PHP operation and operator Usage Summary", "PHP Network Programming Skills Summary", "PHP basic grammar Introductory Course" , "PHP Operation Office Document Skills Summary (including word,excel,access,ppt)", "PHP date and Time usage summary", "PHP object-oriented Programming Introductory Course", "Php+mysql database operation Introductory Course" and " A summary of common PHP database operations tips
I hope this article will help you with the PHP program design.