I am trying to have this php code post variable to itself.
Here is my code:
<?
echo "<form action=\"$_SERVER['PHP_SELF']\" method=\"post\"></form>";
?>
I got a error from that: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/cpthk/public_html/project/test.php on line 2
And if I change to:
<?
$self = $_SERVER['PHP_SELF'];
echo "<form action=\"$self\" method=\"post\"></form>";
?>
Then if works fine. I realized everytime I have $SERVER['PHP_SELF'] with the double quote"" at the sides, it will have problem. Even if I do:
<? echo "$_SERVER['PHP_SELF']"; ?>
Still gives me the error. What wrong with my coding?
Thanks.