php扩张加载原理demo
作者:互联网
php 的扩展原理就是函数的动态注入和调用,简单demo如下
head.h
=============
typedef struct function{
char * name;
void (* handler)();
} FUNCTION;
FUNCTION * function_list[10];
helloword.c
===========
#include <stdio.h>
#include "header.h"
int helloword(){
printf("%s","helloword");
}
FUNCTION f=
{
"helloword",
helloword
};
void get_module()
{
function_list[0] = &f;
}
maic.c
===============
#include <stdio.h>
#include "head.h"
extern void get_module();
int main(){
get_module();
function_list[0]->handler();
}
标签:function,helloword,include,get,demo,module,php,FUNCTION,加载 来源: https://www.cnblogs.com/bigmiao/p/15750549.html