User Tools

Site Tools


uphp:functions:strval

strval

WMPRO, WMMINI FW >= 1.0 WMMEGA FW >= 2.0

Return the string equivalent of a number

Description

string strval ( mixed $value )

Type cast an integer or float variable into a string variable

Parameter

$value: A number (int or float)

Return Values

$value TYPERETURN VALUE
int or floatString equivalent (this is the main use of this function)
arrayEmpty string
stringString (unchanged)

Examples

<pre><?
 
  $i=100;
  $str=strval($i);
  print("The string value of the integer '".$i."' is '".$str."'\r\n");
 
  $f=1.55;
  $str=strval($f);
  print("The string value of the float '".$f."' is '".$str."'\r\n");
 
  $s="100 dollars"
  print("The string value of the string '".$s."' is '".strval($s)."'\r\n");
 
  $arr1=array();            // empty array
  print("strval($arr1)='".strval($arr1)."'\r\n");
 
  $arr2=array("1","2","3"); // array with values
  print("strval($arr2)='".strval($arr2)."'\r\n");
 
?></pre>

The above example will output:

The string value of the integer '100' is '100'
The string value of the float '1.550000' is '1.550000'
The string value of the string '100 dollars' is '100 dollars'
strval($arr1)=''
strval($arr2)=''

Note

This function performs no formatting on the returned value. If you are looking for a way to format a numeric value as a string, please see:

number_format() - Format the number with the specified number of digits of precision

print(f) - Print a formatted string to standard output

sprintf() - Return a formatted string

strftime() - Format a Linux Timestamp using a format string

See Also

intval() - Return the integer value of a number or string

floatval() - Return the float value of a number or string

is_numeric() - Check if a value is numeric (int, float or numeric string)

uPHP Variable Types and Limits

uphp/functions/strval.txt · Last modified: 2021/09/13 05:57 (external edit)