Hướng dẫn php print_r new line
When I run the following code:
the results are concatenated on one line like so: How can I get it to display on separate lines, like so:
asked Dec 15, 2011 at 7:10
You might need to add a linebreak:
If you wish to add breaks between print_r() statements:
answered Dec 15, 2011 at 7:12
spanspan 5,5688 gold badges54 silver badges111 bronze badges 2 to break line with print_r:
The element will format it with any pre-existing formatting, so \n will turn into a new line, returned lines (when you press return/enter) will also turn into new lines. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre
brandito 6878 silver badges19 bronze badges answered Jun 12, 2017 at 16:08
Sen SokhaSen Sokha 1,68614 silver badges15 bronze badges 1 If this is what your browser displays:
And this is what you want:
the easy solution is to add the the
answered Jun 14, 2019 at 8:59
charelfcharelf 2,6293 gold badges25 silver badges39 bronze badges Old question, but I generally include the following function with all of my PHP: The problem occurs because line breaks are not normally shown in HTML output. The trick is to wrap the output inside a
klewis 6,95914 gold badges56 silver badges97 bronze badges answered Dec 10, 2018 at 7:16
ManngoManngo 11.9k8 gold badges70 silver badges91 bronze badges 2 Just echo these :
answered Dec 15, 2011 at 7:12
Jigar TankJigar Tank 1,4541 gold badge13 silver badges23 bronze badges (PHP 4, PHP 5, PHP 7, PHP 8) print_r — Prints human-readable information about a variable Descriptionprint_r(mixed print_r(), var_dump() and var_export() will also show protected and private properties of objects. Static class members will not be shown. Parametersvalue The expression to be printed. return If you would like to capture the output of print_r(), use the Return ValuesIf given a string, int or float, the value itself will be printed. If given an array, values will be presented in a format that shows keys and elements. Similar notation is used for objects. When the
ExamplesExample #1 print_r() example
The above example will output: Array ( [a] => apple [b] => banana [c] => Array ( [0] => x [1] => y [2] => z ) ) Example #2
Notes
See Also
liamtoh6 at hotmail dot com ¶ 12 years ago
simivar at gmail dot com ¶ 5 years ago
$input; Matt ¶ 13 years ago
motin at demomusic dot nu ¶ 15 years ago
reinder at fake-address dot com ¶ 16 years ago
'\'' . $name . '\' : ' ) ; Bob ¶ 13 years ago
henzeberkheij at gmail dot com ¶ 10 years ago
do_print_r($array, $return=false){
bart at mediawave dot nl ¶ 14 years ago
$var1 = 'a'; machuidel ¶ 11 years ago
$array as $key => &$value)
Soaku ¶ 5 years ago .
thbley at gmail dot com ¶ 16 years ago
print_r_xml($arr,$first=true) { lech ¶ 5 years ago
admin at swivelgames dot com ¶ 14 years ago
[0]=" anon at anon dot com ¶ 14 years ago
; Matthew Ruivo (mruivo at gmail) ¶ 15 years ago
Anonymous ¶ 14 years ago
warhog at warhog dot net ¶ 17 years ago
preda dot vlad at yahoo dot com ¶ 9 years ago
eithed ¶ 10 years ago
afisher8 at cox dot net ¶ 13 years ago
is_array($arrayOfObjectsToHide)) { kurt krueckeberg ¶ 13 years ago
"[$k]".' => ';
Alexander ¶ 12 years ago
Simon Asika ¶ 8 years ago
$tabLevel = 1; schizo do not spamme duckie at gmail dot com ¶ 13 years ago
janci ¶ 14 years ago
= new ReflectionClass('Static'); sebasg37 at gmail dot com ¶ 13 years ago
(); Trixor ¶ 5 years ago
brenden at beagleproductions dot com ¶ 14 years ago
general at NOSPAMbugfoo dot com ¶ 17 years ago
Sumit ¶ 7 years ago
ntd at entidi dot it ¶ 7 years ago
Soaku ¶ 5 years ago
= array(" Enthusiastic PHPers ¶ 15 years ago
helpful at maybe dot com ¶ 14 years ago
anymix dot services at gmail dot com ¶ 5 years ago
|