Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
<?php
echo 'a'; // 用于输出字符串
function sum(int $a, int $b): int
{
return $a + $b;
}
echo sum(4.8, 2);
echo '<pre>';
$arr = ['php', 'java', 'python']; // 索引数组
// 同上 $arr = array('php', 'java', 'python');
var_dump($arr); //打印数组,信息全
print_r($arr); // 输出数组
echo '<hr>';
$user = array('id' => 1, 'name' => 'hao', 'email' => 'hao@qq.com');
print_r($user);
$navs = ['首页', '视频教程', '学习路径', 'PHP培训新', '资源下载', '"技术文章'];
$nav = '';
for ($i = 0; $i < count($navs); $i++) {
$nav .= "<a href='' style='padding:0 15px'>$navs[$i]</a>";
}
echo $nav;
$navs = [['id'=>1, 'name'=>'视频教程', 'url'=>'https://www.aqy.com'], ['name'=>'学习路径', 'url'=>'https://www.aqy.com'], ['name'=>'PHP培训新', 'url'=>'https://www.aqy.com'], ['name'=>'资源下载', 'url'=>'https://www.aqy.com'], ['name'=>'技术文章', 'url'=>'https://www.aqy.com']];
$nav = '';
for ($i = 0; $i < count($navs); $i++) {
$nav .= "<a href='{$navs[$i]['url']}' style='padding:0 15px'>{$navs[$i]['name']}</a>";
}
echo $nav;
$nav2 = '';
foreach($navs as $k=>$v){
$nav2 .= "<a href='{$v['url']}' style='padding:0 15px'>{$v['name']}</a>";
}
echo $nav2;
$nav3 = '';
foreach($navs as $k=>$v){
extract($v); // 从关联数组中键名为变量,值为变量的值。
$nav3 .= "<a href='{$url}' style='padding:0 15px'>{$name}</a>";
}
echo $nav3;
echo @$b; // @屏蔽错误
//变量大小写敏感;函数大小写不敏感;
// list() 不是函数,是一种结构
list($a, $b, $c) = $arr; // 批量赋值
echo $a, $b;
ob_clean();
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>提交表单</title>
</head>
<body>
<form action="test.php" method="post">
<label for="uname">用户名</label>
<input type="text" name="uname" id="uname"><br>
<label for="pwd">密码:</label>
<input type="password" name="pwd" id="pwd">
<button>提交</button>
</form>
</body>
</html>
<?php
class NbaPlayer{
public $name;
public $team;
function play(){
}
}
$james = new NbaPlayer; // 对象都需要实例化
var_dump($james);
?>
<script>
// js对象有三种,内部对象new(内置对象);宿主对象DOM BOM; 自定义对象
var d = new Date();
d.getDay();
// alert(d.getDay()); //星期
// alert(d.getHours());
// alert(navigator.appCodeName); //内核
// alert(navigator.platform); //系统
</script>
<?php
$handle = fopen('data.txt', 'r'); // 返回指针资源
var_dump($handle); //resource(3) of type (stream)
// $con = fread($handle,10); // 读取10个字节
$con = fread($handle,filesize('data.txt'));
echo $con;
$pdo = new PDO('mysql:host=localhost; dbname=video', 'root', 'root');
var_dump($pdo); // 对象类型object(PDO)#2 (0) { }
$ch = curl_init();
var_dump($ch); //resource(5) of type (curl)
// null 不是0,不是false,是未定义或清空的变量,是空
根据视频内容又自己演练了一遍,没有什么难以理解的内容。