PDA

View Full Version : redeclare utf8_substr()


djjase
12-08-2009, 12:37 AM
I get this error:

Fatal error: Cannot redeclare utf8_substr() (previously declared in /home/int09999/public_html/calendar/functions/listings.php:88) in /home/int09999/public_html/libraries/phputf8/mbstring/core.php on line 90

If I take out this in the core.php file it works:

function utf8_substr($str, $offset, $length = FALSE){
if ( $length === FALSE ) {
return mb_substr($str, $offset);
} else {
return mb_substr($str, $offset, $length);
}
}

But I get this error when I try to edit anything in the Admin backend:

Fatal error: Call to undefined function utf8_substr() in /home/int09999/public_html/libraries/joomla/utilities/string.php on line 107

This is the code in string.php

function substr($str, $offset, $length = FALSE)
{
if ( $length === FALSE ) {
return utf8_substr($str, $offset);
} else {
return utf8_substr($str, $offset, $length);
}
}

If I take that out it creates more errors in other files

ve9gra
12-08-2009, 08:01 AM
Search the forums for "utf8_substr" and you will see that there is no solution to this problem.

Sorry.

Brian
12-08-2009, 09:42 AM
Their code is trying to declare a function without checking to see if it's already defined.

What is the other program you're using?

MatrixDesigns
12-09-2009, 06:04 AM
If you are savvy enough here is the replacement code:

if(!function_exists('utf8_substr'))
{
// Define Function
function utf8_substr($str, $offset, $length = FALSE){
if ( $length === FALSE ) {
return mb_substr($str, $offset);
} else {
return mb_substr($str, $offset, $length);
}
}
// End if
}

PM me if you wish for more help...
I get this error:

Fatal error: Cannot redeclare utf8_substr() (previously declared in /home/int09999/public_html/calendar/functions/listings.php:88) in /home/int09999/public_html/libraries/phputf8/mbstring/core.php on line 90

If I take out this in the core.php file it works:

function utf8_substr($str, $offset, $length = FALSE){
if ( $length === FALSE ) {
return mb_substr($str, $offset);
} else {
return mb_substr($str, $offset, $length);
}
}

But I get this error when I try to edit anything in the Admin backend:

Fatal error: Call to undefined function utf8_substr() in /home/int09999/public_html/libraries/joomla/utilities/string.php on line 107

This is the code in string.php

function substr($str, $offset, $length = FALSE)
{
if ( $length === FALSE ) {
return utf8_substr($str, $offset);
} else {
return utf8_substr($str, $offset, $length);
}
}

If I take that out it creates more errors in other files

ve9gra
12-09-2009, 07:34 AM
Don't do that. Since the function that is being declared in the calendar is totally different from the one in Joomla, this will most likely break Joomla if you do so.

Brian
12-09-2009, 09:53 AM
I have changed this function name in the calendar for the next release which should resolve this issue with Joomla.

If you'd like to test this new version before it's released, please open a support ticket.