You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PHP语法问题:在指定echo代码中插入img标签报错求助

正确的PHP写法

你之前的语法错误是因为在PHP代码块里又嵌套了<?php ?>标签,这完全没必要——当前已经处于PHP执行环境中,直接把PHP表达式拼接到字符串里即可。另外原代码里还有个标签不匹配的问题(出现了</span>但没有对应的<span>),已经一并修正。

以下是调整后的完整代码:

echo '<h3 class="nome-vendor-cat">',
    $current_cat->name,
    "&nbsp;di&nbsp;",
    '<img src="' . esc_url( get_avatar_url( $post->post_author ) ) . '" />',
    '<a href="' . $vendor_link->get_shop_url() . '" class="nome-vendor">',
    get_usermeta( $post->post_author, 'dokan_store_name' ),
    '</a>',
    '</h3>';

如果需要调整图片的位置(比如放在店铺名称后面、分类名称前面),只需要调整对应代码行的顺序即可。

内容的提问来源于stack exchange,提问作者acfree191

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 05:25:18