易截截图软件、单文件、免安装、纯绿色、仅160KB

自己动手用 C 扩展 PHP

[ZT]自己动手用 C 扩展 PHP
引言:
   有感于大多数人认为 PHP 只是一种弱类型,只能做小型web应用的脚本语言。 与目前的Java, .Net平台有一定的差距,所以决定写一些 PHP 的扩展方法文章,我相信
我们PHPER们通过自己动手写商业扩展,一定能构建出强大的,极速的Web应用,因为扩展本身就是编译型语言编写的(c/c++),而且可以
预先驻留内存的(Apache启动时加载),有了 C/C++ 编写的扩展,我们几乎可以无所不能.
   呵呵,Zend 的说明文档少之又少,真令人头疼 
----------------------------------------------------------
环境要求:  Linux, GCC
首先,我们应该选择如何去构建我们的扩展模块, 有三种方式:
         1. External Modules
        外部模块,也就是编译成共享库,用dl()函数动态加载。
        好处:    (1)不需要重新编译 PHP (2)PHP体积小,因为不需要编译进PHP
        缺点:     (1)每次*.php脚本执行都需要用 dl()去加载,效率较低
               (2)每次都要调用dl()
    2. Built-in Modules
        编译进PHP
        好处:    (1)不需要动态加载,模块在php脚本里面可以直接使用.
            (2)不需要将模块编译成.so共享库,因为直接编译进PHP。
        缺点:    (1)对模块的改变都需要重新编译PHP
            (2)因为编译进PHP,所以PHP二进制文件较大,而且多占点内存
    3. The Zend Engine
        Zend 核心里实现        (略 ... 有兴趣的话可以看 Zend API)
Note: 本人推荐用 第 2 种方式,直接编译进PHP, 但是在下面示例里,我们编译成外部模块
    ,因为,外部模块不需要重新编译 PHP


相关文档:

c判断汉字

#include <windows.h>
int IsGB(PTSTR pText);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
     PSTR szCmdLine, int iCmdShow)
{
 static TCHAR szText[] = {TEXT ("i服,了。uy")} ;
 PTSTR pText;
 int i;
 unsigned char ......

c文件操作

#include <stdio.h>
#include <stdlib.h> //use malloc, free
#include <string.h> //use memset
#include <ctype.h> //use isdigit
#define ERROR_ILLEGAL_CHAR 1 //define error illegal character as 1
#define ERROR_NUMBERS_DIF 2 //define error numbers is not the same in diffe ......

Decrease the size of C:\Windows\Installer

http://social.msdn.microsoft.com/Forums/en/sqltools/thread/07db294a-79e5-4a5a-916c-6a51e44a5aa4
http://www.pcreview.co.uk/forums/thread-211705.php
Download "MsiZap.exe" from http://support.microsoft.com/default.aspx?scid=kb;en-us;290301 ......

C代码规范与运行时长分析模板

/*****************************************************
文件:main.c
功能:测试运行时间(C)!
作者:chinayaosir   QQ:44633197
工具:VC++6.0编译OK!
日期:11/28/2009
代码目录:
//1.包含头文件
//2.main主程序
//不同的算法实现的性能,运行时间相差非常大的!
修改列表:
***************** ......

通过JNI在JAVA与C程序中传递参数

一、编辑Java源文件
=============================================
Hello.java
=============================================
package test;
public class Hello
{
  static
  {
    try
    {
      //此处即为本地方法所在链接库名
&n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号