Home > Blockchain >  str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Time:11-02

I just updated my php version from version 7.3 to version 8.1.10, and then I migrated my CI 3 project to htdocs folder in xampp directory. Then I run my ci3 project and I get an error like this: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated. Filename: core/Output.php Line Number: 442 Backtrace

Then I tried to trace the line of code referred to in system/core/Output.php on line 442 and found this line of code `

$output = str_replace(array('{elapsed_time}', '{memory_usage}'), array($elapsed, $memory), $output);

`

and change it to be like this `

$output = str_replace(array("[elapsed_time]", "[memory_usage]"), array($elapsed, $memory), $output);

`

I hope it can solve my problem, but it can't solve my problem please help let me know if anyone knows how to solve this problem

Thank you to all of you

CodePudding user response:

After I searched some solutions on stackoverflow forums I found this solution and it worked on my problem.

i replaced this line of code :

$output = str_replace(array('{elapsed_time}', '{memory_usage}'), array($elapsed, $memory), $output);

be like this:

$output = $output ? str_replace(array('{elapsed_time}', '{memory_usage}'), array($elapsed, $memory), $output):"";

CodePudding user response:

I think str_replace does not support array as parameters.

check this out https://www.w3schools.com/PHP/func_string_str_replace.asp.

  • Related