Aviel Fedida
Aviel Fedida

Reputation: 4102

Php input value

I am trying to understand this syntax <?=$value;?> in php, For example:

<input type="text" name="user" value="<?=$_POST["user"];?>" id="user">

As i understand it is not some xml syntax becouse the file has to be .php file, Also the:

<? ?> // short opening tags in the <?=$_POST["user"];?> syntax

Is working even if i set short_open_tag = Off, If anyone can please help me understand this syntax and how doe's it working with the short_open_tag = Off, Thank you all and have a nice day.

Upvotes: 1

Views: 224

Answers (4)

Michael
Michael

Reputation: 12802

The <?=$value;?> is short-hand syntax for <?php echo $value; ?>.

As to why it works even with short_open_tags turned off; are you using PHP >=5.4.0? If so, that's expected; it's always available. See here.

Upvotes: 1

Justin
Justin

Reputation: 332

<? ?> is the same as <?php ?>. Since they are inserting a php value $_POST["user"] into the Form they are using the <? ?>

Upvotes: 1

Dipesh Parmar
Dipesh Parmar

Reputation: 27364

try

<input type="text" name="user" value="<?=$_POST['user'];?>" id="user" />

You forget " .

And <?=$_POST['user'];?> is the simple and short form of <?php echo $_POST['user']; ?>

Upvotes: 3

웃웃웃웃웃
웃웃웃웃웃

Reputation: 11984

<input type="text" name="user" value=<?=$_POST["user"];?> id="user">

value=<?=$_POST["user"];?>

Means the value you entered in the input field with name 'user' and submitted.

Upvotes: 1

Related Questions