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