User Tools

Site Tools


uphp:functions:strval

This is an old revision of the document!


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 Value

$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() - Format a string using the format specified using the passed parameters and return a string

strftime() - Format the passed time using the format string

See Also

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

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

is_numeric() - Return 1 if the value is numeric (integer, float or numeric string)

uPHP Variable Types and Limits

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