开发者

What is the meaning of the PHP code "<?=$List?>"?

开发者 https://www.devze.com 2023-01-07 11:35 出处:网络
I knew th开发者_开发问答ere are two ways to represent PHP code start/end. <?php ?> and <? ?>

I knew th开发者_开发问答ere are two ways to represent PHP code start/end.

<?php ?>

and

<? ?>

In this code snippet:

<?php
for($x=5;$x<25;$x=$x+5):
$List .= '<option value="'.$x.'">Greater than '.$x.'% increase</option>';
endfor;
?>

<html>
...
<select name="growth" id="growth">
<option value="">Choose one</option>

<?=$List ?>
</select>

...
</html>

What is the meaning of the <?=$List ?>?


<? is the shorthand version of the opening tag, <?php. The = means to echo the specified string/variable, so the whole thing is shorthand for:

<?php
echo $List
?>


<?php echo $List ?>

The shorttag syntax is deprecated though.

0

精彩评论

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