PHP: Using browscap.ini on shared host. - ini_set() failing

狂风中的少年 提交于 2019-12-08 16:25:22

问题


I'm trying to use get_browser() , unfortunately my page is on a shared host, and I have no access to php.ini.

I have downloaded the latest version of browscap.ini and placed in my document root. I have then added the following:-

if (!ini_set('browscap', '/home/private stuff/browscap.ini')) {
echo "Failed to set browscap";
} else {
echo "browscap = [" . ini_get('browscap') . "]";
}
exit();

But this fails, (nb: the echo statement for the failed condition always shows [] - even if I didn;t have the browscap.ini file the setting should still show up in the ini_get.... shouldn't it?)

I have looked at the previous questions on this and they don't seem to help, any ideas?


回答1:


I hadn't heard of this feature before, but in Googling around I came across phpbrowscap (previously at a this Google Code repo( which is a standalone class that you should be able to use in your hosted environment. The author supports many configuration files and the QuickStart (previously here) looks especially easy.




回答2:


As per the PHP manual, 'browscap' is changeable only in the system php.ini and/or httpd.conf. You cannot set it at the script level.



来源:https://stackoverflow.com/questions/2545910/php-using-browscap-ini-on-shared-host-ini-set-failing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!