Entry
How to call from within a PHP extension other extension's functions ?
Feb 22nd, 2008 03:22
dman, Jonathan Sharp, Jean Gagliardi, http://www.ttnr.org
If you are referring to PHPs source code (written in C) then you would
need to include the propper header file for that function.
Otherwise if you are referring to PHP code calling a function in an
extensions API (most likely written in C) there has to be a
PHP "wrapper" function which points to it. So the short answer, if it's
listed on php.net as a PHP function, you can call it. Otherwise you'd
have to write the wrapper and recompile it yourself.
One more thought, if you are referring to an object in PHP (a class)
and calling another classes function, there are a few ways you can do
it, the easiest would be using ::
Example:
class A
{
function fred(){ echo 'Fred is cool'; }
}
class B
{
function printSomething(){ A::fred(); }
}
$B = new B();
$B->printSomething();
Would print "Fred is cool"
This isn't necessairly the best way of using objects/classes. But it
works.