Jump to content

[SOLVED] How the echo "


garethhall

Recommended Posts

Hello I am on an update page but I cant seem to get the data in the text field. So say we have the following code how could I get the value populated when the text contains " and '. Say I have a book $title = 'The "Big" cat's'

 

Is there a addslases function I can use?

 

<input type="text" name="book" value="<?php echo $title?>" /> // this don't work
<input type="text" name="book" value='<?php echo $title?>' /> // this to don't work

Link to comment
Share on other sites

try <input type="text" name="book" value="<?php echo $title; ?>" /> it was missing the ;

 

The semi-colon is not required when the PHP closing tag appears on the same line. But I would use it anyway.

 

@OP

You want to use htmlentities():

 

<input type="text" name="book" value="<?php echo htmlentities($title); ?>" />

Can't remember if you need to run html_entity_decode() on the value later though.

Link to comment
Share on other sites

try <input type="text" name="book" value="<?php echo $title; ?>" /> it was missing the ;

 

The semi-colon is not required when the PHP closing tag appears on the same line. But I would use it anyway.

 

I din't know that :) learn something new everyday still woulden't do it that way, same as I never use <?=$title;?>

Link to comment
Share on other sites

try <input type="text" name="book" value="<?php echo $title; ?>" /> it was missing the ;

 

The semi-colon is not required when the PHP closing tag appears on the same line. But I would use it anyway.

 

I din't know that :) learn something new everyday still woulden't do it that way, same as I never use <?=$title;?>

 

Same here. Good on ya.

 

@Garethp

You misunderstood the OP. Your code would still mess up the HTML.

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.