I currently using online server and i need to enable the cURL module (change ;extension=php_curl.dll to extension=php_curl.dll in php.ini file). But this file is not accessible and not editable for that online server. How to solve this problems using PHP functions?
-
2PHP functions don't have further access than the userid the webserver is running with. Consult your hosting provider instead.mario– mario2014-05-22 18:57:58 +00:00Commented May 22, 2014 at 18:57
-
Hi. usually you can create you own php.ini and put it to the root of your site,but $mario is right call or text to your hoster to see what is avaliablevolkinc– volkinc2014-05-22 19:14:12 +00:00Commented May 22, 2014 at 19:14
3 Answers
You might want to have a look at ini_set.
PHP Doc link: http://www.php.net/manual/en/function.ini-set.php
string ini_set ( string $varname , string $newvalue )
Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.
Also, as they say in the documentation:
Not all the available options can be changed using ini_set(). There is a list of all available options in the appendix.
2 Comments
The author's real reason for wanting to ini_set() directives dynamically is to access a statically compiled library (curl) in a shared hosting environment. This is not possible in the case of a library which MUST be statically compiled into PHP. The answers are valid for the title of the question but not for the description as what he's attempting to achieve seems impossible given those constraints.
However, you can use the dl() function to dynamically load modules at runtime (if they are not static) https://www.php.net/manual/en/function.dl.php.
However, curl needs to be statically compiled into PHP...
To use PHP's cURL support you must also compile PHP --with-curl[=DIR] where DIR is the location of the directory containing the lib and include directories. In the include directory there should be a folder named curl which should contain the easy.h and curl.h files. There should be a file named libcurl.a located in the lib directory. Beginning with PHP 4.3.0 you can configure PHP to use cURL for URL streams --with-curlwrappers . This feature was moved to PECL as of PHP 5.5.0.
Perhaps if you just need to make a HTTP request, try file_get_contents (http://php.net/manual/en/function.file-get-contents.php), you rarely need curl in practice.