PHP:在共享主机上使用 browscap.ini.- ini_set() 失败 [英] PHP: Using browscap.ini on shared host. - ini_set() failing

查看:106
本文介绍了PHP:在共享主机上使用 browscap.ini.- ini_set() 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 get_browser() ,不幸的是我的页面在共享主机上,我无法访问 php.ini.

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

我已经下载了最新版本的 browscap.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/私人内容/browscap.ini')) {
echo "设置浏览器失败";
}其他{
echo "browscap = [" .ini_get('browscap') ."]";
}
退出();

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

但这失败了,(注意:失败条件的 echo 语句总是显示 [] - 即使我没有;没有 browscap.ini 文件,该设置仍应显示在 ini_get 中.... 不应该它?)

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?

推荐答案

我之前没有听说过这个功能,但是在 谷歌搜索我遇到了 phpbrowscap(之前在 this Google Code repo(这是一个独立的类,您应该能够在您的托管环境中使用.作者支持许多配置文件和 快速入门(以前是 这里) 看起来特别容易.

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.

这篇关于PHP:在共享主机上使用 browscap.ini.- ini_set() 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆