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? Link to comment https://forums.phpfreaks.com/topic/60823-novice-question/ 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']"?> Link to comment https://forums.phpfreaks.com/topic/60823-novice-question/#findComment-302594 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']; ?>"> Link to comment https://forums.phpfreaks.com/topic/60823-novice-question/#findComment-302595 Share on other sites More sharing options...
phat_hip_prog Posted July 19, 2007 Share Posted July 19, 2007 Too true Link to comment https://forums.phpfreaks.com/topic/60823-novice-question/#findComment-302601 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. Link to comment https://forums.phpfreaks.com/topic/60823-novice-question/#findComment-302609 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. Link to comment https://forums.phpfreaks.com/topic/60823-novice-question/#findComment-302612 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... Link to comment https://forums.phpfreaks.com/topic/60823-novice-question/#findComment-302617 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 Link to comment https://forums.phpfreaks.com/topic/60823-novice-question/#findComment-302623 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.