Darkmatter5 Posted January 22, 2009 Share Posted January 22, 2009 I'm trying to echo this to my page: <form><input type='button' onclick='parent.location="res_addgame.php"' value='Add game'><input type='button' onclick='parent.location="res_addmovie.php"' value='Add movie'></form> But the following code only prints out: echo "<form><input type='button' onclick='parent.location='res_addgame.php'' value='Add game'><input type='button' onclick='parent.location='res_addmovie.php'' value='Add movie'></form>"; <form><input type='button' onclick='parent.location='res_addgame.php'' value='Add game'><input type='button' onclick='parent.location='res_addmovie.php'' value='Add movie'></form> How do I echo out a double quote or output an equivalent? Link to comment https://forums.phpfreaks.com/topic/141949-solved-help-with-echo-with-and/ Share on other sites More sharing options...
aebstract Posted January 22, 2009 Share Posted January 22, 2009 put a \ in front of it. echo "<form name=\"lalala\">"; Link to comment https://forums.phpfreaks.com/topic/141949-solved-help-with-echo-with-and/#findComment-743266 Share on other sites More sharing options...
gevans Posted January 22, 2009 Share Posted January 22, 2009 You need to escape some characters in php; e.g. <?php $foo = "To use a double quote here you need to "escape it" a single quote is 'fine'"; $bar = 'If you wrap with 'single quote' it works the "other way round"'; for you code use; <?php $foo = '<form><input type="button" onclick="parent.location='res_addgame.php'" value="Add game"><input type="button" onclick="parent.location='res_addmovie.php'" value="Add movie"></form>'; Link to comment https://forums.phpfreaks.com/topic/141949-solved-help-with-echo-with-and/#findComment-743267 Share on other sites More sharing options...
gevans Posted January 22, 2009 Share Posted January 22, 2009 EDIT, the bbcode gets rid of ym back slashes; eg1 <?php $foo = "To use a double quote here you need to \"escape it\" a single quote is 'fine'"; $bar = 'If you wrap with \'single quote\' it works the "other way round"'; eg2 <?php $foo = '<form><input type="button" onclick="parent.location=\'res_addgame.php\'" value="Add game"><input type="button" onclick="parent.location=\'res_addmovie.php\'" value="Add movie"></form>'; Link to comment https://forums.phpfreaks.com/topic/141949-solved-help-with-echo-with-and/#findComment-743270 Share on other sites More sharing options...
Darkmatter5 Posted January 22, 2009 Author Share Posted January 22, 2009 Perfect thanks! Link to comment https://forums.phpfreaks.com/topic/141949-solved-help-with-echo-with-and/#findComment-743277 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.