Home  >  Article  >  Backend Development  >  PHP string operation judgment example analysis for negative values

PHP string operation judgment example analysis for negative values

墨辰丷
墨辰丷Original
2018-06-01 16:19:211390browse

This article mainly introduces the judgment of negative values ​​​​in PHP string operations. The example analyzes the judgment skills of negative values ​​​​in PHP string operations. Friends in need can refer to it.

The details are 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 running result output is as follows:

1
int -1
boolean true

Summary:

The logical value of the string '-1' is true;

Summary: The above is all of this article Content, I hope it will be helpful to everyone’s study.

Related recommendations:

PHP Detailed explanation of grouping two-dimensional arrays according to key

PHP page jump to implement delayed jump Transfer method

PHP method of getting page execution time

##

The above is the detailed content of PHP string operation judgment example analysis for negative values. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn