PHP internal #2 - how .so extensions are loaded by PHP

General discussion on PHP
Post Reply
test1636
Posts: 6
Joined: Tue Jun 14, 2016 10:47 pm

PHP internal #2 - how .so extensions are loaded by PHP

Post by test1636 » Wed Jun 15, 2016 5:41 pm

Suppose two simple libraries written in C.
There is a common function called foo() in each library (yes it is bad but it is an example).
Each library contains an additional function: foo1() and foo2(). They call foo()

If i compile a main program which load the 2 libraries. This program will call foo1() and foo2().
It results by calling the foo function of the first library.
I think this is normal.

So i made this test: i create 2 PHP extension and i put a foo() function in each extension.
When my module is loaded (MINIT_FUNCTION), i call foo() function.
This time, i notice that foo() functions are called properly.

For thoses tests, i put a simple printf in foo() functions ("hello i am the first/second foo function")

So my question is: How does PHP work in order to avoid the conflict between foo() functions ?
I have no prefix and no MACRO on my foo function.

Thanks

User avatar
eranb2
Posts: 10
Joined: Sun Jan 18, 2009 10:40 am

Re: PHP internal #2 - how .so extensions are loaded by PHP

Post by eranb2 » Thu Jun 16, 2016 8:25 am

This is not really a PHP issue... its a C question and the answer depends on the OS you are running - google it
Eran

test1636
Posts: 6
Joined: Tue Jun 14, 2016 10:47 pm

Re: PHP internal #2 - how .so extensions are loaded by PHP

Post by test1636 » Thu Jun 16, 2016 12:19 pm

i have google it.
I have also made some tests.
I think it is a question about how php engine loads extension. I dit not manage to find the solution by looking php code source...

Thanks

Post Reply