PHP data type of the integral type detailed

Source: Internet
Author: User
Tags scalar

  types of data supported in PHP

8 Types of data are supported in php . and A form of pseudo-type in 3. 8 Types of data are divided into the following 3 major categories, the first one is our scalar type, scalar type it can only store a single data, the second class is our composite type, the third is a special type, Divided into these three categories, that first we come to a category of the view.

In the first class, the scalar type is divided into the following four small classes, the first one is our shaping, the integer you can use int to represent an integral type, or an integer to represent an integer . The second one is our floating-point type, which can be represented by float or double -precision floating-point or real Real. The third one is that our Boolean type can be represented by bool or boolean . The fourth one is me. String types can represent strings by string.

  data Type -- integral type

Well, first of all, let's take a look at our whole type first, the whole type we've been writing, written to us 123, my age , this is an integral type, or -123 , it all represents the integer type, then we write the decimal, but also can write those values, can write octal number, hexadecimal, this represents the integer type. Then we also need to know a storage range for the integral type.

the storage range of the integer type, signed:-21 billion, remember a approximate range can be, to the positive between billion;-2 billion ~21 billion.

That is unsigned, and that is 0 to billions;0~42 ; such a form. That also need to know that, since there is a storage range, then we say that two integral type must be equal to shaping it? Not necessarily, because more than the storage range of the integer type will produce a phenomenon, called overflow phenomenon, what meaning we say, take a liter of cup, you want to pack 10 liters of water, The hole will not fit ah who went out.

So since you want to load 10 liters of water, you can only take a bigger container to install it, then it will take our floating-point type, that floating-point type first need to know its storage scope than the integer size. Well, don't worry. First of all, to write a few integral type, to see.

let's declare an integer variable and first write a $int = 1; Echo $int; you will see a 1 , then write another $int =-12; the same negative number also represents our integral type, echo $int; And then write down an octal number. $int =0x123; then echo $int; you can wait and see if it's the value you want. $int =0xffff; this represents a hexadecimal number.

  <?php

  Header (' Content-type:text/html;charset=utf-8 ');

  declaring an integral type

  $int = 1;

  Echo $int, '
‘;

  $int =-12;

  Echo $int, '
‘;

  $int =0x123;// octal

  Echo $int, '
‘;

  $int =0xffff;// Hex

  Echo $int, '
‘;

Run this example.

That first 1,-12 This needless to say, then look again.

when you write an octal number, it shows a 291. Then remember the reality of the time is to convert this 8 binary into decimal, the display is a decimal. The same you see 16 binary 0xffff turn into decimal is a form of our 65535 .

And now you see that these values all represent integers, but you can't say that light sees how we get to the type of a variable. We can do this by printing the details of the variable, which can be written in this function, commonly used functions.

The first one:var_dump (); using this function to print the details of the variable directly to the browser, you have to tell me to print that variable, you can print one at a time or you can print multiple, such a form.

then we'll use this var_dump (); A bit Var_dump ($int); Let's declare a $int =0;

Now you will see the integer 0 in the browser , which is the details of printing an integral type.

first see that this is the type of the variable, the parentheses inside this 0 is the value of the variable, this need to know, that see int has proved to be integral type, no problem.

  <?php

  Header (' Content-type:text/html;charset=utf-8 ');

  declaring an integral type

  $int = 1;

  Echo $int, '
‘;

  $int =-12;

  Echo $int, '
‘;

  $int =0x123;// octal

  Echo $int, '
‘;

  $int =0xffff;// Hex

  Echo $int, '
‘;

  How to get the type of a variable

  $int = 0;

Var_dump ($int);//int (0)

original link:http://www.maiziedu.com/wiki/php/data/

PHP data type of the integral type detailed

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.