strval() to get string from a variable

echo strval(34)."<br>"; //34
echo strval(12.34)."<br>"; // 12.34 
echo strval(12.340)."<br>"; // 12.34 
echo strval(.34)."<br>"; // 0.34 
echo strval(0.34)."<br>"; // 0.34 
echo strval(-0.34)."<br>"; // -0.34 
echo strval('plus2net')."<br>";// plus2net
From any type of data ( variable ) we can get string output. This can be used to convert any numeric data to string.

The return value is string.

Application using strval()

Find the sum of every 2nd digit of any integer.
for($i=0; $i<strlen($my_num); $i++){
	if(($i % 2) ==0){
	$sum=$sum + $my_num[$i];	
Output is 16
Declaring variables Cookies to store Infomation Getting Type of Variable var_dump() empty()
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 All rights reserved worldwide Privacy Policy Disclaimer