In ordinar way - this can be derermined using phpinfo() output. To programmatically determine the PHP extension folder use:
php -r 'echo ini_get("extension_dir");'