易游网-易游模拟器

 找回密码
 立即注册
查看: 1957|回复: 0

[php] php学习知识点摘要汇总

[复制链接]

3382

主题

3401

帖子

38

积分

超级版主

Rank: 8Rank: 8

积分
38

技术达人

发表于 2020-12-14 09:33:58 | 显示全部楼层 |阅读模式
本帖最后由 eumnq8 于 2020-12-14 09:42 编辑

1、var_dump();打印变量
2、print_r();简单打印
3、header("ContentType:text/html;charset:utf-8");//设置页面返回编码
4、php支持html和php混编,不建议,要做html模板和php分离
5、date_default_timezone_set("PRC");//设置php时区,保证date出来的时间对
6、date('y-m-d H:m:s', 时间戳);格式化时间戳   Y四位,y 2位
7、mysql_fetch_object($result);取一个对象
8、mysql_query(“set names 'utf8'”);设置链接数据库的编码
9、$link = @mysql_connect("127.0.0.1","newsuser","pwd") or die("数据库连接失败");
10、mysql_select_db("news",$link);
11、mysql_query($sql);
12、php中加空格 “  ”
13、trim() ltrim() rtrim() ;//去除字符串两边空白符
14、substr('abcded', 0, 4);取字串
15、$time = time();获取时间戳,使用这个函数记得设置时区
16、now();获取当前日期字符串型
17、$id = $_GET["id"]
18、header(location:list.php);//强制跳转到list.php页面
19、双引号里面的$变量才会被解析,单引号不会解析
20、global关键字在函数内使用全局变量;
21、md5();这个函数求md5
22、include_once "";包含一次
23、会话相关操作
session_start()
session_destroy()
$_SESSION["xxxx"];
isset();
unset();

24、history.back(-1);返回历史的前一步,js脚本
25、html里所有的img都要加alt字段
所有的a都要加title,有利于seo

26、floor(9.6) == 9;向下法取整
ceil(9.6)==10;向上取整

27、php下标数组也是从0开始

28、
limit 1;取一条
limit 0,10;从0起始,取10条;
$total = mysql_num_rows($result);//查询结果集行数

29、
exit();退出脚本执行

30、
<input type="file" name="upfile">
php接受上传文件 用$_FILES["upfile"];php上传文件

31、print_r(输出变量到html)

32、move_uploaded_file();移动文件

33、php有文件最大上传尺寸限制,在php.ini配置里

34、file_exsits();判断文件是否存在

35、unlink();删除文件

<form action="addad_sub.php" enctype="multipart/form-data" method="post">
</form>
current(数组) == $total

36、$smarty = new Smarty;可以括号,可以省略

37、require 也可以引用文件

38、$arr = array('xh'=>12, 'xx'=>34); 一維數組
$arr = array(array('a','b'), array('3', '4'));二維數組
索引數組可以采用$arr.0  $arr.1



您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|易游网-易游模拟器 Copyright @2015-2021 ( 浙ICP备15028007号-1 )

GMT+8, 2024-5-2 22:13 , Processed in 0.035154 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表