Home > Backend Development > PHP Tutorial > PHP return语句的另一个作用_PHP

PHP return语句的另一个作用_PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 14:36:00
Original
1259 people have browsed it

一直以为,return只能出现在函数中,直到看了bbPress的代码:

<&#63;php
require_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' );
 }
 return;
}

Copy after login

难道 return 还能出现在函数之外?这在C语言是无法想象的。

查了一下 PHP 手册:如果在一个函数中调用 return 语句,将立即结束此函数的执行并将它的参数作为函数的值返回。如果在全局范围中调用,则当前脚本文件中止运行。

唉,受C语言的毒害太深了。

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template