umar
umar

Reputation: 3133

difference between <?php echo $pno ?> and <?=$pno?>

Please help me out regarding a small line of code. I want to get the value in the textbox.

Sometimes this line works:

<td width="292" bgcolor="#EDEFF4"><input name="pno" type="text" id="pno" value="<?php echo $pno?>"/></td>

and sometimes this line works:

<td width="292" bgcolor="#EDEFF4"><input name="pno" type="text" id="pno" value="<?=$pno?>"/></td>

So whats the difference between

<?php echo $pno ?> 

and

<?=$pno?>

Upvotes: 1

Views: 173

Answers (3)

Alex Bailey
Alex Bailey

Reputation: 1679

There is none.

<?= 'foo' ?>

translates to

<?php echo 'foo' ?>

But be aware:

<?= 'foo' ?>

Is a short tag syntax which can be disabled in the php.ini so sometimes you can't rely on it if the server administrator disabled it

(More information on using shorttags Are PHP short tags acceptable to use?)

Upvotes: 5

Michiel Pater
Michiel Pater

Reputation: 23033

You should use

<?php echo $pno; ?>


Both options are supposed to give the same result. However, if you would like to use the latter option, your webserver must have the option short_open_tag turned on. It is a compatibility issue.

Upvotes: 3

tvkanters
tvkanters

Reputation: 3523

They're both the same, the latter is just a shorthand. The shorthand does require your PHP settings to allow it, though.

Upvotes: 2

Related Questions