为了账号安全,请及时绑定邮箱和手机立即绑定

如何在 PHP 中正确连接

如何在 PHP 中正确连接

PHP
森林海 2022-01-24 09:41:48
我有下一个代码,它不打印 var 的值$item。我如何让它返回项目的值。<?php$item = "wewewe";$plu = $_POST[‘plu’];$img = $_POST[‘img’];$password = $_POST[‘password’];echo '<tr>  <td><input type="checkbox"></td>  <td>'.$item.' </td>  <td>666</td>  <td> <img src="apple.jpg" alt=""> </td></tr>' ?>
查看完整描述

2 回答

?
忽然笑

TA贡献1806条经验 获得超5个赞

试试这个:


<?php

$item = "wewewe";

$plu = (isset($_POST['plu']))?$_POST['plu']:'';

$img = (isset($_POST['img']))?$_POST['img']:'';

$password = (isset($_POST['password']))?$_POST['password']:'';

?>

<tr>

  <td><input type="checkbox"></td>

  <td><?= $item ?></td>

  <td>666</td>

  <td> <img src="apple.jpg" alt=""> </td>

</tr>

希望能帮助到你。


查看完整回答
反对 回复 2022-01-24
?
一只斗牛犬

TA贡献1784条经验 获得超2个赞

在 php 中,如果你想打印一个值或一个变量,你必须使用“echo”关键字。


试试这个 :


<?php echo '

<tr>

 <td><input type="checkbox"></td>

 <td> '.$item.' </td>

 <td>666</td>

 <td> <img src="apple.jpg" alt=""> </td>

</tr>'; ?>


查看完整回答
反对 回复 2022-01-24
  • 2 回答
  • 0 关注
  • 190 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号