This article analyzes the method of judging the negative value of PHP string operation. Share to everyone for your reference, specific as follows:
$a = '-1 ';
$b = (int) $a;
$c = Is_numeric ($a);
if ($a) {
echo 1;//echo 1
} else {
echo 2;
}
Var_dump ($b); Int ( -1)
var_dump ($c);//True
The output of the run results is as follows:
1
Int-1
Boolean true
Summarize:
The logical value of the string '-1 ' is true;
More interested in PHP related content readers can view the site topics: "PHP string (String) Usage summary", "PHP Mathematical Arithmetic Skills summary", "PHP Array" operation Skills Encyclopedia, "PHP Sorting algorithm Summary", "PHP commonly used traversal algorithm and skills summary", "PHP Data structure and algorithm tutorial", "PHP Programming Algorithm Summary", "PHP Regular Expression Usage summary", "PHP operation and operator usage Summary" and "PHP common database Operation skill Summary"
I hope this article will help you with the PHP program design.