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