Jack
Jack

Reputation: 753

Quotation Marks when the variable is printed or echoed

I'm getting the variable within textbox as $Dataprefix=hello, but what I want is to show the values within quotes as "hello" Here's my code.

 Data File Prefix Name:&nbsp; <input size="5" name="dataprefix" type="text"  value="<?php echo $Dataprefix;?>">

and it shows value within textbox as hello

Upvotes: 2

Views: 60

Answers (4)

JPickup
JPickup

Reputation: 388

If you want the variable wrapped quotation marks to be displayed then :

echo '"'.$Dataprefix.'"';

If you only want to echo the variable when it satisfies "hello" :

echo ($Dataprefix === 'hello'? $Dataprefix : '' );

If this isn't what you are looking for then I would recommend rephrasing your question.

Upvotes: 1

Narendrasingh Sisodia
Narendrasingh Sisodia

Reputation: 21437

Then try this way it'll work for you

Data File Prefix Name:&nbsp; <input size="5" name="dataprefix" type="text"  value='"<?php echo $Dataprefix;?>"'>
                                                                                   ^^                        ^^ 

Upvotes: 3

Saty
Saty

Reputation: 22532

Use echo to print variable

value="<?php echo $Dataprefix;?>">

Upvotes: 1

Manashvi Birla
Manashvi Birla

Reputation: 2843

You missed the echo. Try this

Data File Prefix Name:&nbsp; <input size="5" name="dataprefix" type="text"  value="<?php echo $Dataprefix;?>">

Upvotes: 2

Related Questions