Blogger Information
Blog 14
fans 0
comment 1
visits 6529
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
8月22日作业
狼图腾的博客
Original
595 people have browsed it

实例

1.多分析结构

<meta charset="UTF-8">
<h3>分析结构</h3>
<?php
//数组建立
$city = ['北京','上海','深圳','广州'];
echo $city[0],'<br>';
echo $city[1],'<br>';
echo $city[2],'<br>';
echo $city[3],'<br>';
// 多分析结构
$grade = 89;
if ($grade <60) {
    echo '<p>你得补考</p>';
} else if ($grade >= 60 && $grade <80) {echo '<p>你很优秀</p>';}
else if ($grade >= 80 && $grade <100) {echo '<p>你是学霸</p>';}

2、变量类型和检测

<meta charset="UTF-8">
<h3>变量类型和检测</h3>
<?php
//标量:单值变量,数值,字符串,布尔,基本数据类型
//复合类型:多值变量,数组Array,对象Object
//特殊类型:资源,null

$age = 30;
$salary = 3560.88;
$name = 'xiaowang';
$isMarried = true;
echo $name,'年龄是:',$age,'工资', $salary,'是否结婚:',$isMarried;
echo '<br>';
echo print $name,'年龄是:',$age,',<span style="color:red">工资</span>', $salary,'是否结婚:',$isMarried;
//数组
$books = ['php','java','windons','html','css'];
echo '<pre>';
print_r($books);
//对象
$student = new stdClass();
$student->name = '小小';
$student->course = 'php';
$student->grade = '80';
echo $student->name;
echo '<hr>';;
//变量检测 is_null(),
$val1;
$val2 = null;
$val3 = 'ss';
@var_dump(is_null($val1) ? true : false);
@var_dump(is_null($val2) ? true : false);
@var_dump(is_null($val3) ? true : false);
echo '<hr>';
//empty(),
$str1 = '';
$str2 = [];
$str3 = 0;
@var_dump(empty($str1) ? true : false);
@var_dump(empty($str2) ? true : false);
@var_dump(empty($str3) ? true : false);
//isset();

运行实例 »

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

手写作业:什么是变量的作用域?
答:1.全局作用域,在函数外部直接使用;
    如:$sisteName ='PHP中文网'
   2.局部变量,仅限在函数内部使用;
    如:function hello () {global $sisteName ='wee';  }
   3.静态变量,在函数内部创建,仅在内部使用并执行后只不会消失。


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