Description
The var_dump() function is used khổng lồ display structured information (type and value) about one or more variables.
Bạn đang xem: Using The Var_Dump Function In Php
Version:
(PHP 4 và above)
Syntax:
var_dump(variable1, variabl2, ....variablen)Parameter:
variable1variable2---------variablen | The variable being checked | Required | Mixed* |
*Mixed: mixed indicates that a parameter may accept multiple (but not necessarily all) types.
Return value:
Nothing
Pictorial presentation of PHP var_dump() function

Example -1:
";echo var_dump($var_name2)."";echo var_dump($var_name3)."";echo var_dump($var_name4)."";echo var_dump($var_name5)."";echo var_dump($var_name6)."";?> output :
int(678)string(4) "a678"string(3) "678"string(14) "darkedeneurope.com"float(698.99) float(125689.66) View the example in the browser
Example -2 :
Output :
array(4) <0>=> int(99) <1>=> string(10) "darkedeneurope.com" <2>=> float(67899.99) <3>=> array(3) <0>=> string(1) "X" <1>=> string(1) "Y" <2>=> int(1) View the php var_dump() function using array variable in the browser
Redirect the đầu ra of var_dump() function in a string
We have already learned that var_dump() function is used khổng lồ display structured information (type và value) about one or more expressions.The function outputs its result directly khổng lồ the browser. In the following example the output đầu ra of the var_dump() function stored in a variable as a string, therefore we can manipulate the output. Khổng lồ execute the example we have used two php functions ob_start() & ob_get_clean(). Ob_start() function turns output buffering on where as ob_get_clean() function gets current buffer contents and delete current output buffer.
");echo substr($out,0,20);?> đầu ra :
string(27) "Var_dump output in a string" string(27) "Var_dumpView the output đầu ra in the browser
PHP var_dump() vs print_r()
The var_dump() function displays structured information (type và value) about one or more variables.
Xem thêm: Điện Thoại Iphone 6S Plus 16Gb ( A1687 Là Iphone Gì Hay Nhất 2022
The print_r() function displays human-readable information about a variable.
See the following two examples :
output đầu ra :
array(4) <0>=> string(6) "Banana" <1>=> string(5) "Apple" <2>=> string(5) "Mango" <3>=> string(7) "Coconut" Output :
Array ( <0> => Banana <1> => táo apple <2> => Mango <3> => Coconut )Practice here online :
See alsoPHP Function Reference
Previous: unsetNext: var_export
Share this Tutorial / Exercise on : Facebookand Twitter
PHP: Tips of the Day
Converting an integer to a string in PHP
You can use the strval() function lớn convert a number lớn a string.
From a maintenance perspective its obvious what you are trying to bởi vì rather than some of the other more esoteric answers. Of course, it depends on your context.
$var = 5;// Inline variable parsingecho "I"d lượt thích $var waffles"; // = I"d like 5 waffles// String concatenation echo "I"d lượt thích ".$var." waffles"; // I"d like 5 waffles// The two examples above have the same end value...// ... & so vày the two below// Explicit cast $items = (string)$var; // $items === "5";// Function call$items = strval($var); // $items === "5";Ref : https://bit.ly/2WS4c9l