php混编写法有错误 在网上学习一个小项目中有一段混编代码,如下 :
<br /><table border="1" width="500px"><br /><tr bgcolor="silver"><td>投票项</td><td>描述</td><td>票数</td><td><a href="#">投票</a></td></tr><br /><?php foreach ($this->items as $item) {?> <br /><br /><tr><td><?=$item['name']?></td><td><?=$item['description']?></td><td><?=$item['vote_count']?></td><td><a href="#">投票</a></td></tr><br /><?php }?><br /></table><br /> Copier après la connexion
运行之后 html页面无数据显示。
经过我的测试 ,$this->items 里面是存在数据的。
所以应该是php混编写法的问题,
谁懂的,帮我把错误指出一下。非常感谢
------解决方案-------------------- = echo $item['name']?>
------解决方案-------------------- 投票项 描述 票数 投票 items as $item) {?> 投票
试一下这个?如果不能用,你把这个打印出来的值我看看
------解决方案-------------------- 如果连
投票 都不能出来的话,
那只能理解为$this->items不是一个数组。
print_r($this->items);看看
------解决方案-------------------- 检查一下你是否开启了
短标签 ,如果没有
那么就把=$item['name']?>
=$item['description']?> =$item['vote_count']?> 改成~~~~~------解决方案-------------------- <br /><table border="1" width="500px"><br /><tr bgcolor="silver"><td>投票项</td><td>描述</td><td>票数</td><td><a href="#">投票</a></td></tr><br /><?php foreach ($this->items as $item) {?> <br /> <br /><tr><td><?php echo $item['name']?></td><td><?php echo $item['description']?></td><td><?php echo $item['vote_count']?></td><td><a href="#">投票</a></td></tr><br /><?php }?><br /></table><br /><br /><br /> Copier après la connexion
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Derniers articles par auteur
2025-02-26 03:58:14
2025-02-26 03:38:10
2025-02-26 03:17:10
2025-02-26 02:49:09
2025-02-26 01:08:13
2025-02-26 00:46:10
2025-02-25 23:42:08
2025-02-25 22:50:13
2025-02-25 21:54:11
2025-02-25 20:45:11
Derniers numéros
2025-03-18 17:12:12
2025-03-14 11:44:41
2025-03-14 11:42:06
2025-03-14 11:06:10
2025-03-13 12:08:12
Recommandations populaires
Tutoriels populaires
Plus>
Recommandations populaires
Derniers téléchargements
Plus>