What is the function of print_r () with 2nd parameters?

Source: Internet
Author: User
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.

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.