var_dump(): Gives all information about a variable

<?php
$var=5;
echo var_dump($var); // Output int(5)
echo "<br>";
$var='5';
echo var_dump($var); // Output  string(1) "5" 
echo "<br>";
$var=5.8;
echo var_dump($var); // output float(5.8) 
echo "<br>";
$var=+5;
echo var_dump($var); // Output int(5)
echo "<br>";
$var=-5;
echo var_dump($var); // Output  int(-5) 
echo "<br>";
$var='a123';
echo var_dump($var); // output  string(4) "a123" 
echo "<br>";
$var=True;
echo var_dump($var); // output  bool(true)
?>
Output is here
int(5) 
string(1) "5" 
float(5.8) 
int(5) 
int(-5) 
string(4) "a123" 
bool(true)
By using var_dump function we can get all details about the variable used. This function returns nothing and can take more than one variable as input. Let us try some examples.
$a=5;
var_dump($a);
The above code will return like this
int(5)
Now let us try bit different by using one string variable
$a='testing';
var_dump($a);
The output is here
string(7) "testing" 
We get all information about the string variable $a in above line. The length of the string is 7 here. Now let us try by using more than one variable.
$a=5.9;
$b='testing';
var_dump($a,$b);
Output is here
float(5.9) string(7) "testing"
We can add one array variable to our input to var_dump function.
$a=5.9;
$b='testing';
$ar=array('testing',' only ', ' at ', ' plus2net');
var_dump($a,$b,$ar);
The output is here
float(5.9) string(7) "testing" array(4) 
{ [0]=> string(7) "testing" [1]=> string(6) " only " [2]=> string(4) " at " [3]=> string(9) " plus2net" }
Declaring variables Getting Type of Variable isset() empty()
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    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 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer