Jump to content

values with '' and ""


M.O.S. Studios

Recommended Posts

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

$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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.