【发布时间】:2014-10-14 10:59:39
【问题描述】:
我遇到了一个问题。在我网站的首页上,我收到以下警告:不推荐使用:不推荐使用函数 ereg()。昨天它工作正常。我在谷歌搜索并得到我们必须用“preg_match”替换。我做到了,但问题是一样的。
代码如下:
<?php
/*CSS fixed for some browser*/
$browser=$_SERVER['HTTP_USER_AGENT'];
if(ereg('MSIE 6', $browser)) {
// hack IE here
?>
<link href="<?php echo JURI::base();?>/templates/crnatoday/templates/template_ie6.css" rel="stylesheet" type="text/css" />
<?
} else if(ereg('MSIE 7', $browser)) {
// hack IE here
?>
<link href="<?php echo JURI::base();?>/templates/crnatoday/templates/template_ie7.css" rel="stylesheet" type="text/css" />
<?
} else if(ereg('Safari/([0-9].[0-9]{1,2})', $browser)){
// hack safari here
?>
<link href="<?php echo JURI::base();?>/templates/crnatoday/templates/safari.css" rel="stylesheet" type="text/css" />
<?
} else if(ereg('Firefox/2', $browser) && ereg('Windows', $browser)) {
// hack firefox2
?>
<link href="<?php echo JURI::base();?>/templates/crnatoday/templates/firefox2_win.css" rel="stylesheet" type="text/css" />
<?php
} else if(ereg('Firefox', $browser) && ereg('Mac', $browser)) {
// hack firefox2
?>
<link href="<?php echo JURI::base();?>/templates/crnatoday/templates/firefox_mac.css" rel="stylesheet" type="text/css" />
<?php
} else if(ereg('Mozilla/([0-9].[0-9]{1,2})', $browser)) {
// hack mozilla here
} else {
// hack other here
}
?>
请帮忙找出来。
【问题讨论】:
-
那么,您使用的是哪个 joomla 版本?你在哪里替换了
ereg()它仍然在你的代码中? -
@andy 我正在使用 Joomla 3.3.3。我在 template.php 中替换了发生错误的地方。
-
如果您的模板必须为每个浏览器提供单独的自定义 CSS 文件,那么它就是一个制作不佳的模板。我的建议只是删除所有代码并简单地加载 1 个 CSS 文件
-
@bcmcfc 我已经在一个月前将 Joomla 1.5 升级到 Joomla 3.3.3。