What is the function of print_r () with 2nd parameters? This post was last edited by u012314326 at 17:04:39
Http://cn2.php.net/manual/zh/function.print-r.php
1. "print_r () will move the array pointer to the last edge. You can use reset () to bring the pointer back to the beginning"
What does this sentence mean?
2. "If you want to capture the output of print_r (), you can use the return parameter. If this parameter is set to TRUE, print_r () does not print the result (this is the default action), but returns its output ."
What does this sentence mean?
3. What is the role of this function in actual programming?
Reply to discussion (solution)
$ Arr = Array ("1" => 1, "2" => 2 );
$ Result = print_r ($ arr, TRUE );
Echo $ result;
1. "print_r () will move the array pointer to the last edge. You can use reset () to bring the pointer back to the beginning"
$ Ar = array ('a' => 1, 'B' => 2); echo current ($ ar); // 1print_r ($ ar ); echo current ($ ar); // 1
The description is outdated.
2. "If you want to capture the output of print_r (), you can use the return parameter. If this parameter is set to TRUE, print_r () does not print the result (this is the default action), but returns its output ."
$ Ar = array ('a' => 1, 'B' => 2); $ s = print_r ($ ar, 1 );
3. What is the role of this function in actual programming?
This function is generally used and debugged.