1 简单 PHP语法
1 PHP 代码位置:
<?php
$a = 123
?>
2 声明变量
$a = 123
$str = 'hhh'
$arr = [1,2,3]
3 输出语句:
1 echo $str //输出字符串
2 print_r($str) //输出字符串 + 数据结构
3 var_dump($arr); //输出字符串 + 数据元素类型
4 功能:
1 die() //结束运行, 且有返回值
2 header('Content-Type:text/html;charset=utf-8') //解决乱码
5 字符串:
1 $x = 'hello' //单引号字符串, 内部不可识别变量
2 $y = "hello" //双引号字符串, 内部可识别变量
6 接收前端数据: $_GET $_POST $_REQUEST
2 MySQL
1 常见数据库: oracle / mysql / server / MongoDB /..
2 数据库 MySQL: 存储数据的仓库
3 MySQL 常用的数据类型: varchar / int / float / text / enum /..
4 MySQL 语句
------------------------------------------------------------------------------------
1 增加 (insert into)
INSERT INTO user (name,sex,age) VALUES ('$name','$sex','$age')
2 删除 (delete)
delete from user where id=4; //#删除id=4的数据
3 修改 (update)
update user set age='24',sex='女' where id=1 //#修改 user表中 id=1的数据,中的 sge 和sex
4 查询 (select)
1 select * from user where sex='男' //查询表中所有sex="男"的数据
2 select * from user where age>'18' //查询表中所有age>18的数据
3 select * from user where user='$user' and pass='$pass' //查询账号和密码都符合的数据
------------------------------------------------------------------------------------
3 MySQL 可视化操作 (Navicat)
1 创建链接
2 创建数据库
3 创建表
4 设计表
5 添加数据