פרק 29. Creating Extensions

תוכן העניינים :
Compiling Modules

We ' ll start with the creation of a very simple extension at first , which basically does nothing more than implement a function that returns the integer it receives as parameter . דוגמה 29-1 shows the source .

דוגמה 29-1 .




הערה :

Compiling Modules

The first method should definitely be favored, since, as of PHP 4.0, this has been standardized into a sophisticated build process. The fact that it is so sophisticated is also its drawback, unfortunately - it's hard to understand at first. We'll provide a more detailed introduction to this later in the chapter, but first let's work with the default files.




































The module shown earlier in דוגמה 29-1 can be enabled with --enable-first_module or --enable-first_module=yes .

The command to compile the module simply instructs the compiler to generate position-independent code ( -fpic shouldn't be omitted) and additionally defines the constant COMPILE_DL to tell the module code that it's compiled as a dynamically loadable module (the test module above checks for this; we'll discuss it shortly). After these options, it specifies a number of standard include paths that should be used as the minimal set to compile the source files.