Split dlopen/dlsym into helper method.

Reduce copypasta for shared code between dl() and `php --modinfo`