Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
406 views
in Technique[技术] by (71.8m points)

php - putting print_r results in variable

In PHP I can say:

print_r($var);

What I can't do (at least I don't know how) is:

$var_info = print_r($var);

How can I accomplish the effect of putting the results of a print_r inside a variable?
PHP v5.3.5

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

When the second parameter is set to TRUE, print_r() will return the information rather than print it

$var_info = print_r($var,true);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...