tags:

views:

26

answers:

2

I want to load an extension within a Php file as I don't have access to the php.ini file.

I tried:

ini_set('extension','php_gd2.dll');

With the file in the same directory as the Php page but it did not work.

Must it always be done with in php.ini or can it be done like the above?

A: 

Extensions are generally loaded at runtime, which is in many server cases start of http server. So this is rather impossible UPDATE - I was wrong, see Mark Baker answer, and really unneeded. On shared hosting environments you will certainly not have access to such feature (because it is way too much risk) and when you have access to php.ini... Why not to use it?

UPDATE: If you're not even having access to php.ini there's no way anyone will give you the access to such dangerous feature as custom extensions (unless the admin's bad at it). The extension has access to the internals of PHP and can really mess with the server.

Tomasz Struczyński
A: 
if (!extension_loaded('php_gd2')) {
    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
        dl('php_gd2.dll');
    } else {
        dl('php_gd2.so');
    }
}

But note that it won't work with all SAPIs; and is explicitly disabled when running in safe mode or PHP is built with zts support.

Mark Baker
Thanks. Already tried that. Saw it on Phps website.
Thanks for your help. I'll try to sort it out using what you said. Might be doing it wrong