PHP function dl()Loads a PHP extension at runtime

<?php
// Example loading an extension based on OS
if (!extension_loaded('phpsolutions')) {
if (
strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
dl('php_phpsolutions.dll');
} else {
dl('phpsolutions.so');
}
}

// Or, the PHP_SHLIB_SUFFIX constant is available as of PHP 4.3.0
if (!extension_loaded('phpsolutions')) {
$prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
dl($prefix . 'phpsolutions.' . PHP_SHLIB_SUFFIX);
}
?>


We can use linux “nm” or “objdump” command to list symbols in object files…

# nm -C phpsolutions.so
# objdump -s phpsolutions.so

2 Responses to How can we use PHP to access shared library functions?

  1. Anonymous says:

    To be sure along with your thoughts here and that i really like your website! I’ve bookmarked it to ensure that I’m able to revisit & read more down the road.

  2. Anonymous says:

    Hey! Wanted to leave a comment. I must say i enjoyed reading this article. Carry on the awesome effort.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.