fredley Posted July 19, 2007 Share Posted July 19, 2007 I'm trying to echo the line <form method="post" action="<?=$_SERVER['PHP_SELF']"?> but i get an error. What's the best way to deal with all those special charachters? Quote Link to comment Share on other sites More sharing options...
phat_hip_prog Posted July 19, 2007 Share Posted July 19, 2007 <form method="post" action="<?php echo $_SERVER['PHP_SELF']"?> Quote Link to comment Share on other sites More sharing options...
akitchin Posted July 19, 2007 Share Posted July 19, 2007 still wont work - you'll need to drop out of PHP before that last quote: <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> Quote Link to comment Share on other sites More sharing options...
phat_hip_prog Posted July 19, 2007 Share Posted July 19, 2007 Too true Quote Link to comment Share on other sites More sharing options...
fredley Posted July 19, 2007 Author Share Posted July 19, 2007 I don't think you understand, this line is part of a while loop, so I can't drop out of php, i have the line echo '<form method="post" action="<?=$_SERVER['PHP_SELF']"?>'; in my loop and it causes an error. Quote Link to comment Share on other sites More sharing options...
akitchin Posted July 19, 2007 Share Posted July 19, 2007 that would be because you're in PHP already - you don't have to open PHP tags to echo a variable when you're already in it: echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'"'; have a read in the manual about strings and variable interpolation / concatenation. Quote Link to comment Share on other sites More sharing options...
phat_hip_prog Posted July 19, 2007 Share Posted July 19, 2007 lol, I love the big picture... it's all in the detail... Quote Link to comment Share on other sites More sharing options...
chronister Posted July 19, 2007 Share Posted July 19, 2007 I don't think you understand, this line is part of a while loop, so I can't drop out of php, i have the line echo '<form method="post" action="<?=$_SERVER['PHP_SELF']"?>'; in my loop and it causes an error. Yes you can drop out of PHP anytime you need to. If your already in php in this line, then use echo '<form method="post" action="'.$_SERVER['PHP_SELF'] .'">'; consider this.... <?php $x=0; while($x < 6) { ?> <!-- drop out of php in the middle of the loop --> <a href="someurl.html" class="<?=$x ?>" >A Link</a><br> <?php $x++; } // start it back up to finish the loop ?> THis is not a wonderful example, but it works. One of the great things about PHP is that you can drop in and out of it as you see fit. Those folks who have 25 lines of echo ' pure html' can save a lot of trouble if they just drop out of php when they need to use html and back in when they need php just for reference, <?php echo $xyz ?> is the same as <?=$xyz ?> they will do the exact same thing with a few less characters. hope it helps Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.