Blogger Information
Blog 21
fans 0
comment 0
visits 12346
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
is_null,empty,isset,全局函数和静态函数运行
许增颜
Original
600 people have browsed it

代码如下:

实例

<?php
// is_null运用
$a;
$b = null;
$c = '许增颜';
unset($c);
var_dump(is_null($a));
var_dump(is_null($b));
var_dump(is_null($c));
echo "<hr color='red'>";
// empty运用
$d = '';
$e =[];
$f = null;
$g = 0;
var_dump(empty($d));
var_dump(empty($e));
var_dump(empty($f));
var_dump(empty($g));
echo "<hr color='green'>";
// isset运用
$h = 'is yan';
var_dump(isset($h));
echo"<hr color='gray'>";
$username = '麻花藤';
// $GLOBALS['uesrname'];
function word()
{  
    global $username;
    return $username;
}
    echo word();
function hello()
{

          static $nuble = 1;   

          return '第'.$nuble.'次输出'.$nuble++;

           }
    echo "<hr color='seagreen'>";
    echo hello();
    echo hello();
    echo hello();
    echo hello();
    echo hello();
    echo hello();
?>

运行实例 »

点击 "运行实例" 按钮查看在线实例

手抄作业:

QQ图片20180416151446.jpgQQ图片20180416151450.jpg

效果图:

@BA1LZ)]@V$JN1HO8Q44NC0.png

                                             课程总结:

                    is_null  :以下条件会返回true;

  1. 变量已经声明但未赋值;

  2. 给变量直接初始化为null;

  3. unset()删除一个变量值,默认为true;

                    empty:以下条件会返回true;

  1. 空字符串,空数组

  2. 值直接设置null值

  3. 值直接flase值

  4. 值直接设置为0;

                isset : 和is_null反操作会返回true;

                变量的作用域

  1. 全局:函数之外创建的;

  2. 局部:函数内创建的;

  3. 静态:函数内创建的,仅可在函数中使用;

                 什么是函数

函数 :是脚本中具有特定功能的代码段,可以重复声明;

基本语法:

  1. 声明function(argfunCname){代码段}

  2. 表达方式:funCname = function(args){代码段}

  3. 引用方式   echo args();

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post