开发者

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

开发者 https://www.devze.com 2023-02-19 11:16 出处:网络
Please help me out regarding a small line of code. I want to get the value in the textbox. Sometimes this line works:

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?>


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?)


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号