What type of data does PHP obtain from the database?

Source: Internet
Author: User
: This article mainly introduces the type of data that PHP obtains from the database. if you are interested in the PHP Tutorial, please refer to it. What some code can do today is: 1. read data from the database 2. judge the value and process the subsequent business logic based on the judgment result

Step 1: Read fields from the database: in table $ table_name, the Id field data type is int

Select Id from $ table_name

$ Id = $ value ['id'];

Step 2: judge the value: if ($ id = 1 ){....}

Because the subsequent logic is not executed, I print the $ id. the true value is 1.

Then I did what every programmer would do: deny the reality-how can this be wrong? it is clearly like this, this is not possible (I am always happy here ~). I finally began to have all kinds of doubts. then I saw it ), the returned result is: string! Therefore, in PHP, when judging the value obtained from the database, use = to be careful. Then, the problem is solved.

I asked the great god. The Great God said that php was originally a weak language. no one specified the type of data returned by a select statement .. The bug has been found for so long, so it is sent ..

The above section describes the types of data that PHP obtains from the database, including the relevant content, and hopes to help those who are interested in the PHP Tutorial.

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.