The alternative usage of the PHP return statement is more than just in the function, the return statement _php tutorial

Source: Internet
Author: User
Tags bbpress

The alternative usage of the PHP return statement is not only in the function, but the return statement


Share another function of the PHP return statement, and see a wonderful way to use it in the Bbpress code.

Always think that return can only appear in the function until the bbpress code is seen:

<?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 unthinkable in the C language.

Check the PHP manual: If you call the return statement in a function, the execution of the function is terminated immediately and its arguments are returned as the value of the function. If called in the global scope, the current script file aborts the run.


Problems with the return statement in PHP

Return is back AH.
Echo is the output. You can also print
Return is not an output,

Questions about return statements in PHP functions

Yes, logically, when executing to a return, the following statement is no longer executed, and if one is not executed, the following may be executed.
But the second return in this program is not used, and will never be executed.

http://www.bkjia.com/PHPjc/880264.html www.bkjia.com true http://www.bkjia.com/PHPjc/880264.html techarticle The alternative usage of the PHP return statement is not just in the function, the return statement shares the other function of the PHP return statement, a wonderful way to see it in the Bbpress code. Always thought ...

  • 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.