Page 1 of 1
Another newbie question: PHP Deprecated: Function ereg()..
Posted: Mon Jun 07, 2010 2:44 pm
by insodoneva
I just found this error in my log:
"PHP Deprecated: Function ereg() is deprecated in …line 61."
And here is the line:
Code: Select all
$enable_contact = $params->get( 'enable_contact' );
Can anyone please help me fix this?
The only ereg I can see in the document is however on line 121:
Code: Select all
$br = ( !empty( $_SERVER['USER_AGENT'] ) ) ? strtolower( $_SERVER['USER_AGENT'] ) : strtolower( $_SERVER['HTTP_USER_AGENT'] ) ;
if(ereg("msie", $br))
{
$document->addStyleSheet( 'modules/mod_login/assets/css/colorbox-ie.css' );
}
Re: Another newbie question: PHP Deprecated: Function ereg(
Posted: Mon Jun 07, 2010 2:53 pm
by Jonah Bron
Get rid of all
eregi()s. Use
preg_match(), or, if you're not using regex, compare
strpos() to false (use triple equal comparison, ===).
Re: Another newbie question: PHP Deprecated: Function ereg(
Posted: Tue Jun 08, 2010 3:51 am
by insodoneva
Can you please help me with that. I really cannot do the syntax.
Here is the lines before the problematic c line 61:
Code: Select all
require_once ( dirname(__FILE__) . DS . 'helper.php' );
$params->def( 'greeting', 1 );
$type = modLoginHelper::getType();
$return = modLoginHelper::getReturnURL( $params, $type );
$enable_login = $params->get( 'enable_login' );
$enable_register = $params->get( 'enable_register' );
$enable_contact = $params->get( 'enable_contact' );
And here is the only ereg I can find in the entire page:
Code: Select all
$document->addScript( 'modules/mod_login/assets/js/jquery.colorbox.js' );
$document->addScript( 'modules/mod_login/assets/js/div.js' );
$document->addStyleSheet( 'modules/mod_login/assets/css/colorbox.css' );
$br = ( !empty( $_SERVER['USER_AGENT'] ) ) ? strtolower( $_SERVER['USER_AGENT'] ) : strtolower( $_SERVER['HTTP_USER_AGENT'] ) ;
if(ereg("msie", $br))
{
$document->addStyleSheet( 'modules/mod_login/assets/css/colorbox-ie.css' );
Re: Another newbie question: PHP Deprecated: Function ereg(
Posted: Tue Jun 08, 2010 5:45 am
by markusn00b
You have no need for regular expressions in this example. Use strpos(), as suggested, instead.
Code: Select all
if (strpos($br, 'msie') !== FALSE) {
}