str_replace() is not working in aws server returning empty string but working on cpanel and locally str_replace() is not working in aws server returning empty string but working on cpanel and locally nginx nginx

str_replace() is not working in aws server returning empty string but working on cpanel and locally


NOTE: No there is no extra addon/extension in PHP for str_replace.str_replace() is built in string function on PHP 4, PHP 5, PHP 7, PHP 8.

In your code, there can be 2 possible errors. As your code is running local and your files have write permissions.

  1. The First point is - your /config/constants.php file is too big that's why the foreach loop is taken too much time and exit it but for this PHP should throw an error.
  2. The Second point is - You are using laravel config and your $searchfor variable coming from bootstrap/cache/config.php. And you are replacing the value with the config cache value but maybe your /config/constants.php doesn't have this exact key-value or have some spaces between there. I think you got my point.


Check these things are correct or not?

  • Make sure your file exists in the right directory and have write permission
  • Make sure your local and server constants.php has the same contents
  • Remove your bootstrap/cache/config.php manually or by running php artisan config:cache this command re-caches your config again.