Php 使用带有变量字符串声明的函数
今天,我在下面创建这个函数,以显示有关用户、日期、帖子视图、评论等的一些帖子信息。。但是,当我调用其他文件中的函数时,会出现错误,如C:\wamp\www\ype\wp content\themes\yallanpe\functions.php第118行中的Php 使用带有变量字符串声明的函数,php,wordpress,Php,Wordpress,今天,我在下面创建这个函数,以显示有关用户、日期、帖子视图、评论等的一些帖子信息。。但是,当我调用其他文件中的函数时,会出现错误,如C:\wamp\www\ype\wp content\themes\yallanpe\functions.php第118行中的Parse error:syntax error,unexpected.”请告诉我如何更正此错误 <?php function YPE_show_post_info( $post_user, $post_tags, $post_date
Parse error:syntax error,unexpected.”请告诉我如何更正此错误
<?php
function YPE_show_post_info(
$post_user,
$post_tags,
$post_date,
$post_views,
$post_comments
) {
$post_user = '<span class="dashicons dashicons-admin-users"></span> '.the_author_posts_link();.' ';
$post_tags = '<span class="dashicons dashicons-tag"></span>'.the_category(' / ');.'';
$post_date = '<span class="dashicons dashicons-calendar-alt"></span> '.get_the_date(get_option('date_format'));.' ';
$post_views = '<span class="dashicons dashicons-visibility"></span> '.getPostViews(get_the_ID());.' ';
$post_comments = '<span class="dashicons dashicons-admin-comments"></span> '.comments_number('0','1','%');.'';
?>
<p class="text-muted">
<?php
echo $post_user;
echo $post_tags;
echo $post_date;
echo $post_views;
echo $post_comments;
?>
</p>
<?php
}
?>
在之后进行
的投标很好代码>
请尝试以下代码:
<?php
function YPE_show_post_info(
$post_user,
$post_tags,
$post_date,
$post_views,
$post_comments
) {
$post_user = '<span class="dashicons dashicons-admin-users"></span> '.the_author_posts_link().' ';
$post_tags = '<span class="dashicons dashicons-tag"></span>'.the_category(' / ').'';
$post_date = '<span class="dashicons dashicons-calendar-alt"></span> '.get_the_date(get_option('date_format')).' ';
$post_views = '<span class="dashicons dashicons-visibility"></span> '.getPostViews(get_the_ID()).' ';
$post_comments = '<span class="dashicons dashicons-admin-comments"></span> '.comments_number('0','1','%').'';
?>
<p class="text-muted">
<?php
echo $post_user;
echo $post_tags;
echo $post_date;
echo $post_views;
echo $post_comments;
?>
</p>
<?php
}
?>
第118行是哪一行?$post\u user
第118行我认为错误发生在我使用字符串中的函数时,但我不知道如何更正这些错误谢谢你现在与我一起工作