doutenglou6588 2014-03-03 03:14 采纳率: 0%
浏览 10
已采纳

为什么这不起作用? (php if else)[关闭]

Can someone tell me why this is still showing the data?

<? $info = 0;?>
<? if ($info == 1){?>
<div class="col-md-5">
    <img src="<?= $info['n_1_image1'];?>">
</div>
<div class="col-md-4">
    <b>Title:</b> <?= $info['n_1_title1'];?><hr style="margin-bottom: -10px; margin-top: 10px"> <br />
    <b>Total Views:</b> <?= number_format($info['n_1_view1']);?><hr style="margin-bottom: -10px; margin-top: 10px"> <br />
    <b>Duration:</b> <?= gmdate("H:i:s", $info['n_1_time1'])?><hr style="margin-bottom: -10px; margin-top: 10px"> <br />
    <b>Likes:</b> <?= number_format($info['n_1_likes1']);?><hr style="margin-bottom: -10px; margin-top: 10px"> <br />
    <b>Comments:</b> <?= number_format($info['n_1_comments1']);?><hr style="margin-bottom: -10px; margin-top: 10px"> <br /><br />
</div>
<div class="col-md-2">
    <a href="<?=$info['n_1_link1'];?>" target="_blank"> <button type="button" class="btn btn-shadow btn-danger" style="height: 175px; width: 200px">Watch Now!</button></a>
</div>
<br /><br />
 <?}else{?>

<?}?>

I really don't know why this will show data even $info isn't 1

I hope someone can help me thanks!

  • 写回答

1条回答 默认 最新

  • draxq02664 2014-03-03 03:17
    关注

    By default, you need to use <?php instead of <? unless you use short_open_tag=On in your php.ini.

    From the docs:

    When PHP parses a file, it looks for opening and closing tags, which are which tell PHP to start and stop interpreting the code between them. Parsing in this manner allows PHP to be embedded in all sorts of different documents, as everything outside of a pair of opening and closing tags is ignored by the PHP parser.

    PHP also allows for short open tags (which are discouraged because they are only available if enabled with short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option.

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

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?