A detailed explanation of the use of var_dump in php

  • 2020-06-19 09:54:43
  • OfStack

Let's start with an example:


<?php
$a = "alsdflasdf;a";
$b = var_dump($a);
echo "<br>";
//var_dump($c);
$d=var_dump($c);
echo "<br>";
echo $a;
echo "<br>";
echo $b;
echo "<br>";
 Output: 
string(12) "alsdflasdf;a"
NULL
alsdflasdf;a

What does that mean? The var_dump() method is to determine the type and length of a variable and output the value of the variable. If the variable has a value, input the value of the variable and return the data type. This function displays structural information about one or more expressions, including the type and value of the expression. The array expands the value recursively and shows its structure by indentation.
Its format: var_dump (mixed expression [, mixed expression [,...]])
Look at the var_dump syntax:
var_dump (var,var,bar);
Note that the variable in var_dump must exist. If the variable exists but has an empty value, false will be returned. No variable returns NULL. It has its own output function. There is no need to add other output functions.


Related articles: