sean04 Posted July 27, 2010 Share Posted July 27, 2010 This might be a stupid question but what is a better practice? echo" <b> <img src''> </b>"; echo"<b>"; echo"<img src''>"; echo"</b>"; Quote Link to comment https://forums.phpfreaks.com/topic/208976-use-multiple-echos-or-one-echo/ Share on other sites More sharing options...
Zane Posted July 27, 2010 Share Posted July 27, 2010 Personally, for chunks of HTML code, I like to use Heredocs. echo Gotta love the tabs/whitespace MYHTML; Quote Link to comment https://forums.phpfreaks.com/topic/208976-use-multiple-echos-or-one-echo/#findComment-1091547 Share on other sites More sharing options...
Jessica Posted July 27, 2010 Share Posted July 27, 2010 I think it's a personal preference. For the code you posted, I'd actually do ?> <strong><img src="img.jpg" /></strong> <?php Which actually still makes little sense semantically, why are you bolding an image? If there's more HTML than PHP, I exit the PHP if I can. If not, one long variable. Lately I've been using more Heredocs as well. It really depends on your code design and what you're attempting. Someone probably can say "THIS IS BEST" but it won't always be so. Quote Link to comment https://forums.phpfreaks.com/topic/208976-use-multiple-echos-or-one-echo/#findComment-1091681 Share on other sites More sharing options...
sean04 Posted July 27, 2010 Author Share Posted July 27, 2010 Thanks Zanus and jesirose for the reply. I think I'll try Heredocs. As for why I would bold an image, I wouldn't I posted a bad example lol. Thanks again, Sean Quote Link to comment https://forums.phpfreaks.com/topic/208976-use-multiple-echos-or-one-echo/#findComment-1091728 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.