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? Quote Link to comment 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\">"; Quote Link to comment 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>'; Quote Link to comment 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>'; Quote Link to comment Share on other sites More sharing options...
Darkmatter5 Posted January 22, 2009 Author Share Posted January 22, 2009 Perfect thanks! Quote Link to comment 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.