We often use it when debugging in ecshop.
Var_dump ($ Val );
Die ();
To output and view the variables. However, when there are too many variables, the display will be incomplete. At this time, we will consider using print_r
Print_r ($ Val );
Die ();
However, the output content is not neat, so we want to format it and modify it:
Echo "<PRE> ";
Print_r ($ Val );
Echo "</PRE> ";
Die ();
In this way, we can view all the variables, but we don't want to write so much trouble every time, so we can encapsulate our own print Variable Function dump_die ()
Function dump_die ($ Val)
{
Echo "<PRE> ";
Print_r ($ Val );
Echo "</PRE> ";
Die ();
}
We can use this function to check the variables in the future. The problem is where this function is stored. Do we write this function into the file for debugging every time, we still introduce the file for writing this function during every debugging. In fact, there is a position in ecshop to write the global function, that is, mongodes/init. PHP file, which is the file initialized by ecshop. If we put the function here, we can directly call our print function anywhere.
Ecshop debugging statement writing