gpt4 book ai didi

php - 在 cakephp 中生成一个 html 图像元素

转载 作者:太空宇宙 更新时间:2023-11-04 02:02:59 24 4
gpt4 key购买 nike

当我浏览“localhost/ProjectName/users”时,我会得到一个用户帐户图片,如

enter image description here

但是当我浏览“localhost/ProjectName/users/add”时,我会得到一个用户帐户图像,如

enter image description here

但我想看到所有 Action 的正确图像。

我的代码如下。

<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="img/penguen.jpg" class="user-image">
<?php $this->User = ClassRegistry::init('User');?>
<span class="hidden-xs">
<?php if (AuthComponent::user('id')): ?>
<?= AuthComponent::user('username') ?>
<?php endif; ?>
</span>
</a>

最佳答案

<img src="img/penguen.jpg" class="user-image">

是你的错。

利用助手为您生成“有效”链接,问题已解决:

$this->Html->image('penguen.jpg', ['class' => 'user-image']);

切勿将手动 a 或 img 标签与手动构建的 URL 一起使用,这只会出错。

关于php - 在 cakephp 中生成一个 html 图像元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41406199/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com