1.11M Members

php quotes inside quotes

 
0
 

getting a error at $item_id_g'. its bc of the quotes

<?php
    echo"
         <button type='submit' onmousedown='func('$item_id_g');'>test</button>
       ";
?>

i also tried this but didnt work

<?php
        echo"
             <button type='submit' onmousedown="func('$item_id_g');">test</button>
           ";
    ?>
 
0
 

getting a error

Which one? Technically it is correct PHP syntax (apart from the missing space between echo and the double quote perhaps), but not valid HTML/Javascript syntax.

 
0
 

Try it this way (escaping double quotes for javascript arguments):

<?php
echo"
<button type='submit' onmousedown='func(\"$item_id_g\");'>test</button>
";
?>

or this way (escaping double quotes for html attributes):

<?php
echo"
<button type=\"submit\" onmousedown=\"func('$item_id_g');\">test</button>
";
?>
Isn't it about time forums rewarded their contributors?

Earn rewards points for helping others. Gain kudos. Cash out. Get better answers yourself.

It's as simple as contributing editorial or replying to discussions labeled or OP Kudos

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article