Jump to content

[SOLVED] Help with echo with ' and "


Darkmatter5

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.