gettype => it returns the data type of the arguments...
settype => it sets the data type of
the variable and returns the data type of variable.. isset => It Checks the any value is stored in any variable or
not it returns true or false.. unset
=> it will remove the value from the variable.
strval => it returns the string
value from given argument. floatval
=> it returns the float value from given argument. intval => it returns the integer value from given argument. print_r => it prints all the array
Value and index of variable.
Gettype / settype
|
Isset / unset
|
function fun1()
|
<?
|
{
|
function fun4() {
|
$var =5000;
|
$test1 = "hello world";
|
echo gettype($var);
|
echo
isset($test1)?"Yes":"No"; //value is set
|
echo “</br>”;
|
echo "<br>";
|
echo settype($var,”string”) ;
|
echo "Value is = ". $test1;
|
}
|
unset($test1);
|
|
echo "Value is = ". $test1; //Notice
……
|
|
}
|
|
fun4();
|
|
?>
|
Output:
|
Output:
|
Integer
|
Yes
|
string
|
Value is = hello world
|
|
Notice:
Undefined variable: test1 in C:\...\test.php
on line 8
|
|
Value is =
|
Strval / Floatval / Intval
|
Print_r
|
<?
$num = '12.50abcd';
echo "num
is=".$num."<br>";
echo strval($num)."<br>";
//get string value echo floatval($num)."<br>"; //get float
value echo intval($num)."<br>";//get integer value
?>
|
<?
$a[0]="hi";
$a[1]="friends";
print_r($a);
?>
|
Output:
|
Output:
|
num is=12.50abcd
|
Array ( [0] => hi [1]
=> friends )
|
12.50abcd
|
|
12.5
|
|
12
|
|
No comments:
Post a Comment