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;
	}
}

评论

trang chủ - Wiki
Copyright © 2011-2024 iteam. Current version is 2.137.1. UTC+08:00, 2024-11-05 20:30
浙ICP备14020137号-1 $bản đồ khách truy cập$