jamesjmann Posted February 17, 2011 Share Posted February 17, 2011 I've seen this, <?php } ?> in a lot of scripts at the very end of the script. What does this piece of code do? Link to comment https://forums.phpfreaks.com/topic/228007-simple-question/ Share on other sites More sharing options...
Pikachu2000 Posted February 17, 2011 Share Posted February 17, 2011 It closes an open curly brace from earlier in the code. Link to comment https://forums.phpfreaks.com/topic/228007-simple-question/#findComment-1175752 Share on other sites More sharing options...
Maq Posted February 17, 2011 Share Posted February 17, 2011 Right, a lot of PHP scripts will break in/out of PHP to write HTML, JS, etc... But like Pika mentioned, it's to terminate a condition/loop whatever. Link to comment https://forums.phpfreaks.com/topic/228007-simple-question/#findComment-1175754 Share on other sites More sharing options...
iPixel Posted February 17, 2011 Share Posted February 17, 2011 For a visual reference... <?php if($variable == "xxxx") { ?> <!-- DO SOME HTML JS OR OTHER CODE HERE --> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/228007-simple-question/#findComment-1175762 Share on other sites More sharing options...
jamesjmann Posted February 17, 2011 Author Share Posted February 17, 2011 For a visual reference... <?php if($variable == "xxxx") { ?> <!-- DO SOME HTML JS OR OTHER CODE HERE --> <?php } ?> so you can't write the html or javascript within the bracket like this? <?php if($variable == "xxxx") { <!-- DO SOME HTML JS OR OTHER CODE HERE --> } ?> Or can you do it both ways? Link to comment https://forums.phpfreaks.com/topic/228007-simple-question/#findComment-1175802 Share on other sites More sharing options...
KevinM1 Posted February 17, 2011 Share Posted February 17, 2011 Unless you're printing or echoing it, you need to exit PHP. Link to comment https://forums.phpfreaks.com/topic/228007-simple-question/#findComment-1175803 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.