Correction status:qualified
Teacher's comments:
<?php header('content-Type: text/html; charset=UTF-8'); ?> <?php echo '<hr color="red">'; $valk1;//已声明,未初始化 $valk2 = null ;//已声明,初始值为null $valk3 = 'phph';//已声明,并初始化为非null值 unset($valk3);//首先删掉$valk3 var_dump((is_null($valk1) ? TRUE : FALSE)); var_dump((is_null($valk2) ? TRUE : FALSE)); var_dump((is_null($valk3) ? TRUE : FALSE)); /* * 二 */ $strf1 = ''; $strf2 = []; $strf3 = '0'; $strf4 = 0; $strf5 = NULL; $strf6 = FALSE; $strf7 = 110; echo '<hr color="red">'; //简便写法 var_dump(empty($strf1)); var_dump(empty($strf2)); var_dump(empty($strf3)); var_dump(empty($strf4)); var_dump(empty($strf5)); var_dump(empty($strf6)); var_dump(empty($strf7)); //判断用户是否在文本框输入了内容用empty() $chang = 'www.php.cn'; $name = NULL; $hf; echo '<hr color="blue">'; var_dump(isset($var)); var_dump(isset($chang)); var_dump(isset($name)); var_dump(isset($job)); echo '<hr color="blue">'; $sitNAME = '你好!'; function hello() { // global $sitNAME; $username = '郭恒'; // return $sitNAME.',我是:'.$username; return $GLOBALS['sitNAME'].',我是:'.$username; } echo hello(); echo '<hr color="blue">'; //静态变量 function myStatic() { static $num = 1; return '第'.$num.'次输出'.$num++.'<br>'; } echo myStatic(); echo myStatic(); echo myStatic(); echo myStatic(); echo '<hr color="blue">'; //$name = 'guoheng'; //echo $_GET['name']; echo '<hr color="blue">'; function sayname() { return '我的名字叫:'.$_GET['name']; } echo sayname(); /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */
点击 "运行实例" 按钮查看在线实例