PHP string operation judgment example analysis for negative values

墨辰丷
Release: 2023-03-29 09:28:02
Original
1438 people have browsed it

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!