Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
<?php
$num1=100;
$num2=200;
//num1,num2为普通变量 有作用域局限
const NUM3=500;
//用const 声明的为常量,为全局作用域.声明常量时习惯用大写
//普通变量引入函数方法为global
function global1(){
global $num1,$num2;
}
//或者可以用$globals函数提升普通变量为全局作用域变量
function global2(){
($GLOBALS['one'] + $GLOBALS['two']);
}
define('DAY', '/0410');
// echo DAY;
define('DS', DIRECTORY_SEPARATOR);
define('ROOT_PATH', $_SERVER['DOCUMENT_ROOT'] . DAY . '/web1');
// echo ROOT_PATH;
// 数据路径
define('DATA_PATH', ROOT_PATH . '/data');
// 模板路径
define('TMPL_PATH', ROOT_PATH . '/template');
// 公共模板路径
define('TMPL_PATH_PUBLIC', TMPL_PATH . '/public');
// 静态资源路径
define('STATIC_PATH', ROOT_PATH . '/static');
define('STATIC_CSS_PATH', STATIC_PATH . '/css');
define('STATIC_JS_PATH', STATIC_PATH . '/js');
define('STATIC_IMG_PATH', STATIC_PATH . '/images');
<div class="list">
<?php foreach ($news as $k => $v) : extract($v) ?>
<a href="<?= $url ?>"><?= mb_substr($title, 0, 16) ?>...</a>
<?php endforeach ?>