What type of data is PHP extracted from the database?

Source: Internet
Author: User
Tags what php
Here's what the code does today: 1. Read data from a database 2. Determine the value and process the following business logic based on the result of the decision

Step1: Field read from database: Table $table_name, ID field data type is int

Select Id from $table _name

$id = $value [' id '];

Step2: Judgment Value: if ($id = = = 1) {...}

Since the subsequent logic is not executed, I will print out the $id, the true value is 1

then I do what every programmer will do: Just deny the reality-how can this be wrong ah, this is clearly this ah, this is not possible AH (in which has been bored ~). baffled It, I finally began various doubts, and then saw it: = = =, constant equals, so I was disturbed to try: GetType ($ID), unexpectedly return is: string! So in PHP, the value from the database to make judgments when using = = = to be cautious. and then , the problem is solved.

I asked the great God, the great God said that PHP is a weak type of language, a select returned data, no one rules him what type, alas, wayward ah. The bug took so long to get rid of it.

The above describes what PHP data from the database is the type, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • 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.