Difference between return and echo

Source: Internet
Author: User
Difference between return and echo $ key Yongxing village to Zhujia; $ str; & nbsp; $ keysexplode (to, $ key ); & nbsp; $ differences between jso return and echo
$ Key = "Yongxing village to Zhujia ";
$ Str = "";
$ Keys = explode ('to', $ key );
$ Json = @ file_get_contents ("http://api.map.baidu.com/direction/v1? Mode = transit & origin = ". $ keys [0]. "& destination = ". $ keys [1]. "& region = Beijing & output = json & ak = gfPnxaaiPyNIhM7c13eZ1kmEL ");
$ Ar = json_decode ($ json, true );
Array_pai_recursive ($ ar, 'funv ');
Function funv ($ v, $ k)
{
Global $ str;
If ($ k = 'stepinstruction ')
{$ Str. = strip_tags ($ v );}

}
Return $ str;
Why can I write echo in this way, but return doesn't work?
------ Solution --------------------
Big Brother, you are on the first floor in the following mode:
Code line -------
Code line -------
Function ---------
Code line ------
Return mode
Of course not. return is not in the function.

The mode on the second floor is: Set the function mode in the function; if you want to write the function in the class mode, or open the two functions separately, do not nest them, and return in the main function.
------ Solution --------------------
Function funv ($ v, $ k)
{
...
Return $ str;
}


Return value,
Echo display value

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.