PHP settype() function | 您所在的位置:网站首页 › 三菱电机空调与三菱重工空调有什么区别 › PHP settype() function |
Next »229/627« PreviousPHP settype() function In this chapter you will learn: Description for PHP settype() functionSyntax for PHP settype() functionParameter for PHP settype() functionReturn value for PHP settype() functionExample - Set the typeDescriptionWe can use PHP's settype() function to change the type of a variable while preserving the variable's value. Syntaxbool settype ( mixed &$var , string $type )Parameter ParameterMeaning varThe variable being converted. typenew typePossibles values of type are: "boolean" or "bool" "integer" or "int" "float" "string" "array" "object" "null" ReturnReturns TRUE on success or FALSE on failure. ExampleAt first $test_var variable contains 1.23, a floating - point value. Next, $test_var is converted to a string, which means that the number 1.23 is now stored using the characters 8, . , 2 , and 3. After converting $test_var to an integer type, it contains the value 8; the fractional part of the number has been lost. Finally, after converting $test_var to a Boolean, it contains the value true (which PHP displays as 1 ). This is because PHP converts a non - zero number to the Boolean value true. The code above generates the following result. What you will learn in the next chapter: Description for PHP strval() functionSyntax for PHP strval() functionParameter for PHP strval() functionReturn value for PHP strval() functionExample - Convert class to a string Next »« Previous |
CopyRight 2018-2019 实验室设备网 版权所有 |