php value conversion strval(), intval(), floatval(), bool

1.strval ()

 

The strval() function is used to obtain the string value of a variable. PHP version requirements: PHP 4, PHP 5, PHP 7

string strval ( mixed $var )
  • $var: can be any scalar type, but cannot be an array or object.

 

<?php$int_str= 123;var_dump($int_str);$str = strval(123);var_dump($str);?>
int(123)string(3) "123"

 

2.intval ()

 

The intval() function is used to obtain the integer value of a variable.

The intval() function returns the integer value of the variable var by using the specified base conversion (decimal by default). intval() cannot be used for object, otherwise an E_NOTICE error will be generated and 1 will be returned. PHP 4, PHP 5, PHP 7

int intval ( mixed $var [, int $base = 10 ] )
  • $var: The quantity value to be converted to integer.

  • $base: Base used for conversion.

  • Returns the integer value of var on success, and returns 0 on failure. An empty array returns 0, and a non-empty array returns 1.

 

 

 

 

Guess you like

Origin blog.csdn.net/zl17822307869/article/details/113931777