The difference between Print_r and Var_dump

Source: Internet
Author: User

$colors = Array (' Red ', ' blue ', ' green ', ' yellow ');
Print_r ($colors);
Echo ' <br> ';
Var_dump ($colors);

The output results are as follows:
Array ([0] = red [1] = blue [2] = = Green [3] = = yellow)
Array (4) {[0]=> string (3) "Red" [1]=> string (4) "Blue" [2]=> string (5) "Green" [3]=> string (6) "Yellow"}

Var_dump can use any variable, including string, array, number, object, and also indicate the type and length of the variable. void Var_dump(mixed expression [, mixed expression [, ...]])

This function displays structure information about one or more expressions, including the type and value of the expression. The array recursively expands the value and displays its structure by indentation.

Print_r () displays easy-to-understand information about a variable. If a string,integer , or floatis given, the variable value itself is printed. If an arrayis given, the keys and elements are displayed in a certain format. object is similar to an array.

Remember thatprint_r () moves the pointer of the array to the last edge.

Both the Print_r and var_dump can output arrays and objects, but the output of the Print_r to the boolean is not obvious; the var_dump output is verbose and much more commonly used for debugging.

The difference between Print_r and Var_dump

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.