Manixa Posted December 4, 2011 Share Posted December 4, 2011 Hello there fellow programmers, I was just wondering if there was any difference between doing this: echo "Say Something Here"; and this echo "Say "; echo "Something "; echo "Here"; Thank you in advance. Notice: I am aware of the fact that they will output the same thing, my question is regarding resources. Quote Link to comment https://forums.phpfreaks.com/topic/252436-simple-question/ Share on other sites More sharing options...
marcelobm Posted December 4, 2011 Share Posted December 4, 2011 first I would recommend to use single quotes instead of double quotes, because from a resources point of view, double quotes takes more processing resources because PHP checks the string for a variable to resolve it's value inside the string, instead single quotes will be taken just as a string. So back to your question, the second option as is, it would take more resources than the first one, but if you use single quotes instead, should be the same. Quote Link to comment https://forums.phpfreaks.com/topic/252436-simple-question/#findComment-1294258 Share on other sites More sharing options...
Manixa Posted December 4, 2011 Author Share Posted December 4, 2011 Just to make sure I got it right: $dgd="Test"; // #1 echo "<div id='test'>$dgd</div>"; // #2 echo '<div id="test">'.$dgd.'</div>'; #1 takes more resource than #2 right? Quote Link to comment https://forums.phpfreaks.com/topic/252436-simple-question/#findComment-1294259 Share on other sites More sharing options...
marcelobm Posted December 4, 2011 Share Posted December 4, 2011 exactly Quote Link to comment https://forums.phpfreaks.com/topic/252436-simple-question/#findComment-1294260 Share on other sites More sharing options...
Manixa Posted December 4, 2011 Author Share Posted December 4, 2011 Thanks : ) Quote Link to comment https://forums.phpfreaks.com/topic/252436-simple-question/#findComment-1294261 Share on other sites More sharing options...
marcelobm Posted December 4, 2011 Share Posted December 4, 2011 you're welcome Quote Link to comment https://forums.phpfreaks.com/topic/252436-simple-question/#findComment-1294262 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.