Jump to content

Recommended Posts

Posted

I know, heliohost doesn't allow me to use a custom php.ini file, but is there another way to set "display_errors = off"? (besides I have to edit one by one my php)

 

I need this config to hide any bug in my wordpress.

 

thank you for your support.

Posted

A good way of hiding errors is fixing them.

 

 

Or you can suppress them using a try-catch block.

Put all the coding in the try block and place an empty catch block for the errors.

This is will prevent PHP from showing the error.

 

More info about try-catch: http://php.net/manual/en/language.exceptions.php

 

 

EDIT: you do gonna need to know what error occurs.

and what the code for the error is.

You have to google that.

Posted
A good way of hiding errors is fixing them.

 

 

Or you can suppress them using a try-catch block.

Put all the coding in the try block and place an empty catch block for the errors.

This is will prevent PHP from showing the error.

 

More info about try-catch: http://php.net/manual/en/language.exceptions.php

 

 

EDIT: you do gonna need to know what error occurs.

and what the code for the error is.

You have to google that.

 

the easier is put this code

<?php error_reporting(0); ?>

in every PHP file, in the beginning or line one in every PHP file.

 

it will make the error hiding, but i have to edit all my PHP one by one. Too Much PHP i must edit.

Posted
@byron : Just to let you know that your link is broken. ;)

 

Yeah I found a bug in my script and I wanted to fix it before I fixed the link. Right now everytime I search for this tag in a php script:

 

<?php

 

and try to replace it with:

 

<?php

error_reporting(0);

 

I get this:

 

<?<?php

error_reporting(0);

 

For the life of me i can't figure out why it's replacing the php tag like that. Only happens on that tag though?

 

 

 

 

Posted

You can run this php script in each of your directories. Just make sure you don't already have any files with this line in them:

 

error_reporting(0);

 

or it will repeat it again.

 

This will look for any files ending in .php and add error_reporting(0); to them:

 

<?php
$search = "<?php";
$replace = "<?php\nerror_reporting(0);";
foreach (glob("*.php") as $file)
{

# open the file to get existing content
$current = file_get_contents($file);

# search and replace
$fwrite = str_replace("$search", "$replace", $current);

# write the contents back to the file
file_put_contents($file, $fwrite);

echo "<span style=\"color:#000080;\">$file</span><br>";
echo "<span style=\"color:#000060;\">Searched for:</span> <span style=\"background:lightyellow; color:#000060;\">$search</span><br>";
echo "<span style=\"color:#000060;\">replaced with:</span> <span style=\"background:lightyellow; color:#000060;\">$replace</span><br><br>";
}
?>

 

Posted

Thanks jje. I should have the script that I originally posted finished by tomorrow that has forms. You would just type in for instance "index.html" in the file form and then the changes you want to make in the Search and Replace forms and it will change all of your index.html files on your site with a click of the submit button. :)

 

 

  • 8 months later...
  • 2 weeks later...
Posted

With that script you would enter this:

 

1) First choose directory.

 

2) Files: Enter the file name or if you want to change all files that end in php, enter .php

 

3) Search: Enter what area of the file to look for by searching for a part of the code.

 

4) Replace: Replace code your searching for with new code.

 

So if your want to add error_reporting(0); to your php files this would be the entries:

 

Directory: your directory

 

Files: .php

 

Search: <?php

 

Replace: <?php

error_reporting(0);

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...