PHP
ChaosMeta博客
“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.”
展开
-
PHP7的生命周期
一 PHP架构1.1 SAPI 介绍定义:Server Application Programming Interface服务端应用编程端口。他就是php与其他应用交互的接口,php脚本要执行有很多中方式,通过web服务器,或者直接在命令行行下,也可以嵌入其他程序中。SAPI提供了一个和外部通信的接口,常见的SAPI有:cgi、fast-cgi、cli、Apache模块的dll等。...原创 2019-07-08 11:19:48 · 586 阅读 · 0 评论 -
PHP7 内存管理
1. 内存的实现在C语言中,开辟/销毁内存的一对函数。void *ptr=malloc(size); free(ptr);注意:free掉malloc的时候,是怎么知道销毁多大的内存块呢?在申请内存块的头部,保留64位记录内存块的大小,如下图:2.PHP使用了内存池2.1 内存池的介绍 内存池是内核中最底层的内存操作,定义了三种粒度的内存块:chunk、p...原创 2019-05-26 17:22:50 · 895 阅读 · 0 评论 -
PHP7 内核的基本变量
1.字节对齐1.1 好处:为了减少使用的内存 为了提升数据读取的效率 #pragma pack(1) :可以让编译器按照1字节对齐 1.2 结构体和联合体对齐:1.3 替换,在源码里我们经常看见这样的宏,逼格很高1.4 小而巧的zval php7和php5不同的地方有很多,zval,zend_value结构就是其中之一。在zval这个结...原创 2019-05-26 14:56:41 · 275 阅读 · 0 评论 -
十.PHP面向对象
一.继承总结:public和protected成员可以被子类继承,private不能被继承。 一类最多同时继承一个类,不能同时继承多个类。 在子类中可以通过(父类名::父类的方法名或parent::父类的方法名)方法来访问父类的方法,前提是:父类的方法能够被继承才能访问(public、protected)。 如果子类和父类拥有相同的方法名,子类的会重写(覆盖)父类的方法。例子:...原创 2019-05-07 20:44:21 · 217 阅读 · 0 评论 -
九.魔术方法
一.介绍 首先,魔术方法是类、对象的成员方法,只是魔术方法调用、执行的时机是不需要手动调用,自动调用,就跟变魔术似的,所以称之为魔术方法。注意:PHP内置的魔术方法都是以__(两个下划线开头),所以我们在自定义方法时,避免使用__作为前缀 魔术方法是系统自动调用的,程序员不需要手动调用 魔术方法通常是成对出现的二.常用魔术方法:__get、__set应用场景...原创 2019-05-04 14:20:08 · 195 阅读 · 0 评论 -
八.PHP类的使用方法
1.语法说明和其他语言一样,类通过class关键字来定义,类名用大驼峰。定义成员变量。要加上修饰符public、private、protected。 通过->访问修改类内成员变量也和大多数语言一直。注意:访问对象的时候,属性名前不要加$。<?phpclass Count { public function product ($num) { if ...原创 2019-04-27 22:02:52 · 670 阅读 · 0 评论 -
七.PHP操作MySQL
一.开启PHP扩展功能在php.init配置文件中开启二.查看是否开启功能成功<?phpphpinfo();?>三.php操作MySQL流程连接数据库 准备SQL语句 发送SQL语句到MyQSQL服务器 MySQL服务器收到SQL语句后执行 接受MySQL服务器的结果 PHP解析服务器中的结果 关闭连接1.连接数据库函数:mysqli...原创 2019-04-13 21:33:57 · 251 阅读 · 0 评论 -
四.PHP数组
1、数组的定义方式方式一:变量 = array(元素值1,元素值2,元素值3,..................);注意没有定义下标,下标默认从零开始连续递增。方式二:变量 = array(元素1,元素2,元素3,............);注意:如果有些位置没有指定下标,那么下标会在当前数组下表的最大值中开始增长。方式三:数组名 [下标] = 值;2.数组的分类索...原创 2019-04-02 23:40:44 · 105 阅读 · 0 评论 -
三.PHP的预定义变量
定义:预定义变量就是系统自己定义好的变量,直接使用就可以。预定义变量都是以数组的形式存在的。1.$_POSTpost方式传递过来的数据方式,一个表单一个—$POST接收们只能接收表单中的name值。<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>...原创 2019-04-01 23:38:17 · 1016 阅读 · 0 评论 -
二.PHP基本语法
1.php标识符<?php?>说明:告诉php解析器,这里是php的代码位置。注意:如果页面只有php代码,结束标识符可以不写<?php echo 'hello world'2.注释和其他语言一样:单行注释://和# 多行注释:/*注释内容*/3.php和html混编注意:HTML的代码可以写在PHP文件中,PHP的代码只能写...原创 2019-03-31 19:41:21 · 136 阅读 · 0 评论 -
一.PHP介绍
1.php介绍PHP的全称是“超文本预处理器(语言)”,PHP的代码不能直接返回浏览器,原因是浏览器只能识别HTML代码(CSS/JS),所以必须通过“PHP软件(处理器)”进行解析,解析成HTML代码,再返回给浏览器;它是在服务器运行的脚本语言,是必须写在PHP文件中的语言,不能写在HTML文件中,HTML代码可以写在PHP的文件中。脚本语言:其实就是把代码(语言)写在一个规定格式的...原创 2019-03-31 18:13:04 · 1097 阅读 · 0 评论 -
六.PHP调用数据库
1.调用数据库的三种方式: 命令(cmd)、语言调用(PHP、GO)、第三方软件。命令方式:语言调用:<?php//链接数据库$link = mysqli_connect('localhost', 'root', '');//SQL命令的准备$sql = 'show databaces';//讲话命令发送到MySQL服务器$res = mysqli_...原创 2019-04-04 14:51:57 · 2148 阅读 · 0 评论 -
五.PHP函数的使用
1.函数的定义function 函数名(形式参数){ 【return 返回值】;}注意:函数名字的命名规则和变量的是一个。 形参是为了接收实参的数据。<?phpfunction sum() { $sum1 = 10; $sum2 = 20; $res = $sum1 + $sum2; return $r...原创 2019-04-04 14:34:35 · 121 阅读 · 0 评论 -
PHP代码的编译
一.解释行语言也需要编译二.PHP的主要模块首先是Application,就是我们的上层应用——平时写的PHP程序,可以是web应用或者php脚本; 接着是SAPI(Server Application Programming Interface),服务端应用编程接口,sapi通过一系列钩子函数,使得php可以和外围交互数据,并且通过sapi成功的将php本身和上层应用解...原创 2019-08-21 18:47:38 · 2257 阅读 · 0 评论