Home  >  Article  >  php教程  >  php中的字符串如何对负值进行判断

php中的字符串如何对负值进行判断

WBOY
WBOYOriginal
2016-06-13 09:39:462137browse

这篇文章主要介绍了php字符串操作针对负值的判断,实例分析了php字符串操作中针对负值的判断技巧,需要的朋友可以参考下

$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

运行结果输出如下:

1
int -1
boolean true

总结:

字符串 '-1'的逻辑值是true;

【相关教程推荐】

1. php编程从入门到精通全套视频教程 

2. php从入门到精通  

3. bootstrap教程 

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
Previous article:Drupal和微信的结合Next article:Drupal网站的SEO功能

Related articles

See more