Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: Fatal error: Cannot redeclare str_contains() (Read 23395 times) previous topic - next topic

Fatal error: Cannot redeclare str_contains()

Hello
I am receiving this error when trying to publish first project.
thank you

Fatal error: Cannot redeclare str_contains() in C:\xampp\htdocs\edgeestimate\helpers\Functions.php on line 524

/**
 * returns true if $needle is a substring of $haystack
 * @return  bool
 */
function str_contains($needle, $haystack)
{
   return strpos($haystack, $needle) !== false;
}

 

Re: Fatal error: Cannot redeclare str_contains()

Reply #1
Hello
I am receiving this error when trying to publish first project.
thank you

Fatal error: Cannot redeclare str_contains() in C:\xampp\htdocs\edgeestimate\helpers\Functions.php on line 524

/**
 * returns true if $needle is a substring of $haystack
 * @return  bool
 */
function str_contains($needle, $haystack)
{
Hello
I am receiving this error when trying to publish first project.
thank you

Fatal error: Cannot redeclare str_contains() in C:\xampp\htdocs\edgeestimate\helpers\Functions.php on line 524

/**
 * returns true if $needle is a substring of $haystack
 * @return  bool
 */
function str_contains($needle, $haystack)
{
   return strpos($haystack, $needle) !== false;
}


   return strpos($haystack, $needle) !== false;
}[/color]

Yep I have the same with my first project a minute ago. Searched for duplicates in other php-files but nothing.
Who can help ?

Re: Fatal error: Cannot redeclare str_contains()

Reply #2
For now, I have commented out the code and it seems to work for the time being, but definitely need a fix long term.

Re: Fatal error: Cannot redeclare str_contains()

Reply #3
This will probably never be fixed. From what I can tell this has been there for years.

Re: Fatal error: Cannot redeclare str_contains()

Reply #4
Here in Brazil, the error is the same :D


Re: Fatal error: Cannot redeclare str_contains()

Reply #6
I have the same problem. Is there any solution for this issue?


Re: Fatal error: Cannot redeclare str_contains()

Reply #8
Hello @willvin ;

I am rookie about phprad. So i am not sure that understand your question well. But in general i am using phprad classic edition with xampp. I am starting xampp for apache and mySQL then run phprad. I am creating tables and designing pages but when i try to see the results in preview, i am facing with this error message. Everything works fine in real server but not working on localhost.

If you can give me some detail about configuration, i can check all the values and share with you.
(Which parameters should i check and from where?)

Thanks for your quick and kind reply. Yours truly...

Re: Fatal error: Cannot redeclare str_contains()

Reply #9
@pierremataias‍ what I meant was, what was the last design or change you did to your application before you got that error. Without that, I can't determine what might be causing the error and the solution to give.

Re: Fatal error: Cannot redeclare str_contains()

Reply #10
Hello @willvin ;

Now i understand. Normally it is not related with any changes. ( I mean this is not a case that, the preview was working properly at first then in any changes it is not working. )

At the beginning phase i am receiving this message. For example, you just start new project and create a table then publish it or activate the preview. (no change in anything just publish a simple project) you will receive this error.  No changes no different settings or parameters. Just install software and start new project and publish.

As far as i understand from short internet search; a function was used twice or multiple times on Functions.php file.

Here is a simple explanation;

Code: [Select]
If you see error message 'PHP Fatal error: Cannot redeclare function' or similar error message in your script, it means there is a problem with your script code (it tries to declare the same function multiple times).

This error says that your function is already defined. This could mean:

you have the same function defined in two files
you have the same function defined in two places in the same file
the file in which your function is defined is included two times (so, it seems the function is defined two times)
To help with the third point, a solution would be to use include_once instead of include when including your functions.php file -- so it cannot be included more than once.

Thank you very much for your interest.

Re: Fatal error: Cannot redeclare str_contains()

Reply #11
Yeah I understand the error quite well, that is why asked what was the configuration you did before getting the error. Phprad generates specific file when a configuration is made. If you are to preview a project after creation without making any configuration, phprad generates all files plus the core files like the systems folder and semi core files like function.php. Once a configuration like format field value, phprad regenerates the function.php file again with new function/content added. So you have to be specific else I cannot tell what configuration is making phprad generate a function twice. 

Re: Fatal error: Cannot redeclare str_contains()

Reply #12
Had the same Error - PHP-8 is NOT Supported.
Install previous XAMPP 7.4

Re: Fatal error: Cannot redeclare str_contains()

Reply #13
Hi Folks
New here...  ;)

Well, I've got the exact same error.
And to answer Willvins question: I haven't made any configuration changes yet, as this is my first foray into PHPRad.
All I did so far is to create two related tables in MariaDB using HeidySQL.
Then I started XAMPP (in it's Apache, MariaDB-Flavor) and then published what I had up to then.
And hey presto, this error as cited before turned up:
Fatal error: Cannot redeclare str_contains() in C:\xampp\htdocs\repairshack\helpers\Functions.php on line 524[/i]

Any news on this? Is it OK to just comment out this function?
Or is there some other needle in the haystack to tread on ;)

Thanks for your time and effort - much appreciated!

Charlie

Re: Fatal error: Cannot redeclare str_contains()

Reply #14
hello  swisscharles you need to comments line 524 {} after it will work