M.O.S. Studios Posted May 19, 2009 Share Posted May 19, 2009 hey guys this has been a prob for me for a while how do i assign values to a var if it has both '' and "" in it. for example i want to asign this to a variable <div class="mH" onclick="toggleMenu('menu2')">+ Dropdown</div> it become hard for me to do $var="<div class="mH" onclick="toggleMenu('menu2')">+ Dropdown</div>"; or $var='<div class="mH" onclick="toggleMenu('menu2')">+ Dropdown</div>'; dose any one know the answer to that off hand? Link to comment https://forums.phpfreaks.com/topic/158691-values-with-and/ Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 Escape the quotes with backslashes: $var="<div class=\"mH\" onclick=\"toggleMenu('menu2')\">+ Dropdown</div>"; Link to comment https://forums.phpfreaks.com/topic/158691-values-with-and/#findComment-836928 Share on other sites More sharing options...
Ken2k7 Posted May 19, 2009 Share Posted May 19, 2009 $var = <<<HTML <div class="mH" onclick="toggleMenu('menu2')">+ Dropdown</div> HTML; That's called heredoc. But for HTML, why would you assign it to a var? Why not just print it out outside of PHP tags like: <?php // some PHP here ?> <div class="mH" onclick="toggleMenu('menu2')">+ Dropdown</div> <?php // some more PHP here ?> Link to comment https://forums.phpfreaks.com/topic/158691-values-with-and/#findComment-836929 Share on other sites More sharing options...
M.O.S. Studios Posted May 19, 2009 Author Share Posted May 19, 2009 awesome, i ended up doing it by printing out side the php tags, but now i know how to do it thanks guys Link to comment https://forums.phpfreaks.com/topic/158691-values-with-and/#findComment-836934 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.