duanemei2194 2015-09-26 03:59
浏览 8
已采纳

PHP为什么会这样? [重复]

This question already has an answer here:

Specifically speaking, why does the below code work (outputs "test").

<?
    $variable = 'test';
?>

<?=$variable?>

Is this hacky, or functionality?

</div>
  • 写回答

1条回答 默认 最新

  • dongxianglun5163 2015-09-26 04:02
    关注

    <?=?> is a Short Tag for echo(); According to PHP

    Outputs all parameters.

    echo is not actually a function (it is a language construct), so you are not required to use parentheses with it. echo (unlike some other language constructs) does not behave like a function, so it cannot always be used in the context of a function. Additionally, if you want to pass more than one parameter to echo, the parameters must not be enclosed within parentheses.

    echo also has a shortcut syntax, where you can immediately follow the opening tag with an equals sign. Prior to PHP 5.4.0, this short syntax only works with the short_open_tag configuration setting enabled.

    Gives you the also the next example:

    I have <?=$foo?> foo.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案