PHPreturn statements are not used in functions.

Source: Internet
Author: User
Tags bbpress
I always thought that the return statement can only appear in the function until I read the bbPress code. I was surprised. you can see it and share another role of the PHP return statement, the bbPress code shows a wonderful way to use it.

I always thought that return can only appear in the function until I read the bbPress code:

<? Phprequire_once ('./bb-load.php'); bb_repermalink (); // The magic happens here. if ($ self) {if (strpos ($ self, '. php ')! = False) {require ($ self);} else {require (BB_PATH. 'Profile-base. php');} // www. jb51.netreturn ;}

Can return still appear outside of the function? This is unimaginable in the C language.

Check the PHP Manual: if a return statement is called in a function, the execution of the function is immediately ended and its parameters are returned as the function value. If it is called globally, the current script file stops running.

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.