May 3

php的extension 参数配置思考 不指定

admin , 00:14 , 数据库 » 数据库(SQLite) , 评论(0) , 引用(0) , 阅读(2657) , Via 本站原创 | |
搜索
我已经获得阿里云幸运券,准备分享给您。请点击获取  

一直在找一直方法,不去改php.ini 的配置,而是通过动态修改才是来配置,来支持sqlite3.
但是还是不行,因为配置完需要重启。下面为收集的相关比较:

I do not have access to /etc/php.ini and cannot uncomment the lines required to activate php extensions I require.

extensions can only be disabled by editing php.ini 
or use dl() function,such as
***
if (!extension_loaded('php_pdo')) {  
 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { 
  dl('php_pdo.dll');  
  } else { 
  dl('php_pdo.so'); 
  }
 }

***
but :
Warning: dl() [function.dl]: Not supported in multithreaded Web servers - use extension=php_sqlite.dll

Only if the extension has an attribute for that.
Like:
extension.bla_enabled = 0/1 in php.ini

Then you can set it in runtime by:
ini_set("extension.bla_enabled", "0");

ini_set to update settings of php.ini file
We can't change all the configured settings of php.ini file. PHP will permit to change some data by using ini_set function. We will verify after changing the configured data by using ini_get function. Here is the code. Please note the outputs shown here will change based on your server settings when you try.
echo ini_get('mysql.connect_timeout'); // OUTPUT 60
ini_set('mysql.connect_timeout',100);
echo "<br>";
echo ini_get('mysql.connect_timeout'); // output 100

Tags: ,