- Forums
- General Errors
- How A Avoid Godaddy Hosting Putting Extra Slashes On Your Html Output
this page will show you how you can prevent godaddy shared hosting system from putting extra slashes on your html output when you use PHP [4631], Last Updated: Mon Jun 24, 2024
phpguru
Fri Jan 27, 2017
0 Comments
378 Visits
so there you are, coding your scripts, when you noticed your HTML output contains slashes.
the slashes are the back slashes like this one: \
often these slashes are used to escape characters in PHP, but why is godaddy shared web hosting servers adding this..
the answer is simple, magic_quotes_gpc, for security reasons. so what can you do to avoid it?
simple, i created this simple code you can use at the beginning of your script to avoid the $_POST data from godaddy server putting slashes.
// on godaddy G4 hostin, it puts a slash.. for example: i submit: jesus' it comes out: jesus\'
//http://forums.phpfreaks.com/topic/117564-test-for-magic-quotes-gpc/
if(function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()){
$func = create_function('&$value','$value = stripslashes($value);');
array_walk_recursive($_GET,$func);
array_walk_recursive($_POST,$func);
array_walk_recursive($_COOKIE,$func);
}