search
Homephp教程php手册PHP内核学习-01-前期准备

PHP内核学习-01-前期准备

Jun 13, 2016 am 10:56 AM
phpone timethingaboutKernelPreparestudyusofRelated

好久没有写关于PHP的东西了,这次我们讲一下PHP内核相关的知识。

 


按照管理,在开始讲解之前我们先准备一下环境:

 


环境准备:


1. Linux环境,我们使用ubuntu/debian 这两个系统都可以

2. PHP源代码,我们讲解的代码为php-5.4.13.tar.gz,代码大家可以到php官网上面进行下载

3. webserver使用nginx,数据库为mysql

 


其中必须准备php源代码,nginx和mysql可以选择性安装

 


PHP源代码下载完成后,我们将源代码解压,先看一下源代码的目录结构:

build: 这里面主要是一些和源码编译相关的文件

ext:  PHP扩展源码路径

main:


Zend: zend引擎实现目录

pear:  php扩展以及应用仓库

sapi: 各种服务器抽象层代码,如apache,nginx等

TSRM: 线程安全资源管理器

test: 测试代码

 


源码查看的话,我们使用vim+ctags,如果您不明白这个是什么的话,麻烦自己百度一下。

 

 

知识准备:

PHP源码中用到很多的宏定义,在开始之前,我们先温习一下宏相关的知识。

1. 双##号   这个是C语言中的连接符,我们来看一个例子你就明白了。

    #define TEST(name) hello_##name

    我们看一下调用:TEST(world)的结果为: hello_world

    你看明白了吗!

2. 我们再来看一下但个的#号,这个符号的作用是在宏变量替换后的值前面后面添加双引号,我们看一个例子

    #define TEST(str) #str

    我们看一下调用: printf(TEST(HELLO WORLD));的结果为 printf("HELLO WORLD");

3. #line 这个指令用来改变当前的行号和文件名


4. 还有一些常用的宏,这些宏我们会在以后用到时候进行介绍


 

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools