aamsur Posted April 19, 2011 Posted April 19, 2011 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.
Tjoene Posted April 19, 2011 Posted April 19, 2011 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.
aamsur Posted April 19, 2011 Author Posted April 19, 2011 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.
Byron Posted April 19, 2011 Posted April 19, 2011 Here's a script I wrote to edit several files at once. http://byrondallas.heliohost.org/mystuff/adjust_files.txt Put as file name: .php (looks for all files ending in .php) Search: <?php Replace: <?php error_reporting(0);
jje Posted April 19, 2011 Posted April 19, 2011 @byron : Just to let you know that your link is broken.
Byron Posted April 19, 2011 Posted April 19, 2011 @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?
Byron Posted April 19, 2011 Posted April 19, 2011 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>"; } ?>
jje Posted April 20, 2011 Posted April 20, 2011 That is a pretty cool script, byron! Might use it for my site...
Byron Posted April 20, 2011 Posted April 20, 2011 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.
Byron Posted January 1, 2012 Posted January 1, 2012 Here's a more recent version: http://byrondallas.heliohost.org/mystuff/adjust_files_v2.txt 1
soerganda Posted January 14, 2012 Posted January 14, 2012 i want to modified all of my files, and files in all of my folder automaticly.how to use that script ?
Byron Posted January 14, 2012 Posted January 14, 2012 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); 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now