PHP string operation for negative judgment analysis _php tips

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.