Adding functions to PHP
Function Prototype
Even if your function doesn't take any arguments, this is how
it is called.
Function Arguments
NOTE: Arguments can be passed either by value or by
reference. In both cases you will need to pass (pval *) to
getParameters. If you want to check if the n'th parameter was
sent to you by reference or not, you can use the function,
ParameterPassedByReference(ht,n). It will return either 1 or
0.
Variable Function Arguments
Using the Function Arguments
Memory Management in Functions
Setting Variables in the Symbol Table
Arrays in PHP are implemented using the same hashtables as
symbol tables. This means the two above functions can also be
used to check variables inside arrays.
This code declares a new array, named $foo, in the active
symbol table. This array is empty.
If you'd like to modify a value that you inserted to a hash,
you must first retrieve it from the hash. To prevent that
overhead, you can supply a pval ** to the hash add function,
and it'll be updated with the pval * address of the inserted
element inside the hash. If that value is
NULL
(like in all of the above examples) - that parameter is
ignored.
Using the resource list
Typically, these functions are used for SQL drivers but they
can be used for anything else; for instance, maintaining file
descriptors.
The resource types should be registered in php3_list.h, in
enum list_entry_type. In addition, one should add shutdown
code for any new resource type defined, in list.c's
list_entry_destructor() (even if you don't have anything to
do on shutdown, you must add an empty case).
Using the persistent resource table
-
-
Adding runtime configuration directives
-
-
-
-
-
-