|
Posted by Eric on 02/27/06 23:11
So, I've got this simple test PHP document (at the bottom of this
message). It simply puts up a textarea and then submits the form to
itself. The text of the textarea will be placed in 'body' of the $_POST
array. If the $_POST['body'] variable is set, it outputs what 'body'
contains and if not, it simply outputs 'No body var'.
Ok...like, I said...pretty simple.
Now, when I run this on my local machine, I enter:
we'll
in the textarea and when I submit the form, I get:
we'll
However, when I run this form on my webhost, I enter:
we'll
in the textarea and when I submit the form, I get:
we\'ll
Somehow a slash was added before the tick mark. Is this some
configuration option? Does it have to do with how PHP is configured on
the webhost? Does it have something to do with how Apache is configured
on the webhost? Any idea how the slash got there?
I'm just finding this rather odd and hoping to get an explanation.
If it is easily explained, is the best way to get rid of the extra slash
marks to call stripslashes()?
If you want to see it in action on the webhost, just visit:
http://www.ericgorr.net/slash
<?PHP
echo "<html><head><title>hello</title></head>";
echo "<body bgcolor=#eeeeee>";
if ( isset( $_POST['body'] ) )
{
echo $_POST['body'] . "<br>";
}
else
{
echo "No body var<br>";
}
echo "<form name=ContactPlayers method=post action=\"index.php\">";
echo "<textarea cols=80 name=body rows=12></textarea>";
echo "<br>";
echo "<p><input type=submit name=submit value=Send>";
echo " ";
echo "<input type=reset></p>";
echo "</form>";
echo "</body></html>";
?>
[Back to original message]
|