dpv46227 2018-04-01 05:11
浏览 19
已采纳

我需要知道这段代码会发生什么

I am learning PHP and still, I'm at a basic level.I got a code,

echo "2>5-",2>5, " ";

I can't understand what happens here.

If anyone can help me.Thanks.

  • 写回答

3条回答 默认 最新

  • donglin6109 2018-04-01 05:43
    关注

    echo prints stuff into the page. “2>5-“ is a string. So, echo prints “2>5-“ to the page. With echo, you can concatenate using the comma (,) symbol. Although, it is more common to concatenate (that is, join two strings together) using the dot (.) symbol.

    The second 2>5 is not enclosed in quotes. This indicates it is a boolean expression. In PHP, the boolean value false is casted to an empty string ( “”). So, the result of 2>5 is false, which is converted to an empty string.

    Lastly, the “ ” string indicates an escape character designating the start of a new line.

    So, in summary, the expression echo "2>5-",2>5, " ";will output “2>5-” followed by a newline character which has no visual representation. So, you will only see “2>5-” when you run that program.

    Hope this helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致