PHP 剥离“/”在img的结束标签中
我在 while 循环中有这个:
echo '<a class="thumbnail" href="./images/bus-photos/'.$row['file'].'">';
echo '<img alt="'.$row['caption'].'"'. 'src="./images/bus-photos/thumbs/tmb'.$row['file'].'"/></a>';
它输出这个:
<img src="./images/bus-photos/thumbs/tmb134-trap-door.jpg" alt="Trap Door">
我似乎无法关闭图像标签......悲伤但真实。
I have this inside a while loop:
echo '<a class="thumbnail" href="./images/bus-photos/'.$row['file'].'">';
echo '<img alt="'.$row['caption'].'"'. 'src="./images/bus-photos/thumbs/tmb'.$row['file'].'"/></a>';
It outputs this:
<img src="./images/bus-photos/thumbs/tmb134-trap-door.jpg" alt="Trap Door">
I just cant seem to get the image tag closed...sad but true.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的猜测是您正在使用 Firebug 或某种其他类型的 DOM 检查器来查看源代码。如果您实际上想查看 HTML 的样子,请不要这样做。使用“查看源代码”或浏览器的等效项。
也不要使用“查看生成的源”(Web 开发人员附加组件),因为它仍然从 DOM 构建源文档。请参阅 Zend Framework 中的 DisplayGroup 装饰器
另一件事可能会有所帮助......通常更容易如果您闯入和退出服务器端上下文,则可以遵循混合标记和服务器端打印。例如
My guess is you're using Firebug or some other kind of DOM inspector to view the source. Don't do this if you actually want to see what your HTML looks like. Use "View Source" or your browser's equivalent.
Don't use "View Generated Source" (Web Developer Add-On) either as that still builds the source document from the DOM. See DisplayGroup decorator in Zend Framework
Another thing that will probably help... It's usually easier to follow mixed markup and server-side printing if you break in and out of the server-side context. For example
我猜想您在 PHP 中使用了一些 HTML 清理库来删除斜杠 - 在 HTML 中,您不需要关闭某些元素,例如图像和换行符。把它放在一边。
I would guess that you're using some HTML-cleanup-library in PHP that strips out the slash - in HTML, you don't need to close some elements, for example images and newlines. Leave it out.
你的问题的前提是错误的。该输出显然不是来自您认为的代码。
The premise of your question is wrong. That output clearly did not come from the code you think it does.