Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use echo, print_r () and var_dump () in PHP

Shulou Source: shulou.com Published: 2022-06-01 13:12:30 09月10日 Update

This article will explain in detail how to use echo, print_r () and var_dump () in PHP. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Echo: outputs one or more strings.

Print_r (): prints easy-to-understand information about variables (only returns results).

Var_dump (): displays structural information about one or more expressions (returns the type and value of the expression).

$arr=array (array ('axiom = >' 1); json=json_encode ($arr); echo $json ($333), array ('axiom = >' 11), array ($333). # output result / * * [{"a": "1", "b": "2", "c": "3"}, {"a": "11", "b": "22", "c": "33"}, {"a": "111"," b ":" 222", "c": "333"}] * / print_r ($json) # print result / * * [{"a": "1", "b": "2", "c": "3"}, {"a": "11", "b": "22", "c": "33"}, {"a": "111"," b ":" 222", "c": "333"}] * / var_dump ($json) # return result / * * string (88) "[{" a ":" 1 "," b ":" 2 "," c ":" 3 "}, {" a ":" 11 "," b ":" 22 "," c ":" 33 "}, {" a ":" 111", "b": "222"," c ":" 333 "}]" * / print_r ($arr) " # print result / * * Array ([0] = > Array ([a] = > 1 [b] = > 2 [c] = > 3) [1] = > Array ([a] = > 11 [b] = > 22 [c] = > 33) [2] = > Array ([a] = > 111 [b] = > 222 [c] = > 333)) * * / var_dump ($arr) # returned result / * * array (3) {[0] = > array (3) {["a"] = > string (1) "1" ["b"] = > string (1) "2" ["c"] = > string (1) "3"} [1] = > array (3) {["a"] = > string (2) "11" [" B "] = > string (2)" 22 "[" c "] = > string (2)" 33 "} [2] = > array (3) {[" a "] = > string (3)" 111" ["b"] = > string (3) "222" [" c "] = > string (3)" 333 "}} * / about" echo in PHP, That's all for the article "how to use print_r () and var_dump ()" Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

Tags: Results articles information multiple more expressions output good practical content variables characters strings articles knowledge types structures references help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Huawei Docker MariaDB Xiaomi