Auto: http://www.cnblogs.com/mrray/archive/2011/05/18/2050233.html
Strtoupper($ String);// Replace all with uppercase letters
strtolower ( $ string ); // replace all with lowercase letters
Ucwords($ String);// Replace the first letter of a word with an uppercase letter.
The strrpos () function is used to locate the last occurrence of a string in another string.[String,]
PHP Data type conversion is a forced conversion. The PHP data types that can be converted include:
- (INT), (integer): Convert to integer
- (Float), (double), (real): Convert to floating point type
- (String): convert to a string
- (Bool), (Boolean): Convert to boolean type
- (Array): convert to an array
- (Object): Convert to object
There are three conversion methods for PHP Data Types:
- Target type enclosed in parentheses before the variable to be converted
- Use three types of conversion functions: intval (), floatval (), strval ()
- Settype (mixed var, string type)
First conversion method: (INT) (bool) (float) (string) (array) (object)
-
- <? PHP
-
- $ Num1= 3.14;
- $ Num2= (INT)$ Num1;
-
- Var_dump ($ Num1);// Output float (3.14)
-
- Var_dump ($ Num2);// Output int (3)
-
- ?>
Second Conversion Method: intval () floatval () strval ()
-
- <? PHP
-
- $ Str="123.9abc";
-
- $ Int=Intval($ Str);// Converted value: 123
- $ Float=Floatval($ Str);// Converted value: 123.9
-
- $ Str=Strval($ Float);// Converted string: "123.9"
-
- ?>
Third conversion method: settype ();
- <? PHP
-
- $ Num4= 12.8;
-
- $ Flg= Settype ($ Num4,"Int");
-
- Var_dump ($ Flg);// Output bool (true)
- Var_dump ($ Num4);// Output int (12)
-
- ?>