xiaozi 2015-01-29 10:17:35

php中,break 和 continue后面都是可以加层级的;而且在5.4.0版本之后只能为`正数`或者`值为正数的内置常量(包括扩展中定义的常量)`

<?php

const ONE = 1;
define('ONEX', 1);

var_dump(constant('ONE'), constant('ONEX'));
var_dump(E_ERROR);

foreach (range(0, 10) as $i) {
	foreach (range(0, 10) as $j) {
		echo "$i x $j" . PHP_EOL;
		// break ONE; // error
		// break ONEX; // error
		break E_ERROR;
	}
}

首页 - Wiki
Copyright © 2011-2023 iteam. Current version is 2.115.0. UTC+08:00, 2023-05-28 16:54
浙ICP备14020137号-1 $访客地图$