Php Data Type 03

Source: Internet
Author: User
1. Special situations of forced Data Loading: $ a2012abcd; $ bqq2012abcd; var_dump (int) $ a); Output 2012, the non-numeric part will be erased from var_dump (int) $ B); the output is 0, all of which are erased 2. set the Data Type: $ a2012; setType ($ a, int); setType is directly changed

1. Special situations of forced Data Loading: $ a = '22abcd'; $ B = 'qq2012abcd'; var_dump (int) $ a); // output 2012, the non-numeric part is erased by var_dump (int) $ B); // the output value is 0, and all of them are erased. 2. set the Data Type: $ a = 2012; setType ($ a, 'int'); setType is directly changed

1. Forced data replacement

Special cases are as follows:

$ A = '20142abcd ';

$ B = 'qq2012abcd ';

Var_dump (int) $ a); // output 2012. The non-numeric part is erased.

Var_dump (int) $ B); // the output value is 0, all of which are erased.

2. Set the Data Type:

$ A = "2012 ";

SetType ($ a, 'int ');

SetType directly changes the type of the variable in the role body, and forced conversion is used to copy an object.

3. Specific System conversion functions:

Intval () // replace it with an integer

Floatval () // replace it with float

Strval () // convert to string type

Note: These three functions are only applicable to int, float, string, and boolean scalar types and cannot be used for array, resource, or object type variables.

4. Several methods to obtain external form content:

$ _ GET [], $ _ POST [], $ REQUEST []

You can use the three trees operation to check the content of the form, such as obtaining username:

$ Username = empty ($ _ POST ['name'])? "Enter the name": $ _ POST ['name'];

Echo "username: {$ username}"; // You can also remove braces

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.