【问题标题】:WordPress & BuddyPress Outputting PHP to pageWordPress 和 BuddyPress 将 PHP 输出到页面
【发布时间】:2017-02-21 03:42:52
【问题描述】:

我在自定义的 BuddyPress 小部件 (latest-articles.php) 中有一段代码,它落在 => 部分上,并将之后的所有内容输出到屏幕上。这是代码部分:

    $infohub_args = array(
    'post_type' => array('article','post'),
    'posts_per_page' => 8, 
    'order' => 'DESC', 
    'post_status' => 'publish'
);
$infohub_loop = new WP_Query($infohub_args);

这是输出到屏幕而不是小部件内容的内容:

array('article','post'), 'posts_per_page' => 8, 'order' => 'DESC', 'post_status' => 'publish' ); $infohub_loop = 新的 WP_Query($infohub_args); */ $post_max = 8; $all_post = 数组(); $article_cat = get_terms(array('taxonomy' => 'articles', 'hide_empty' => true ));

基本上'=>'部分之后的所有内容都会显示在屏幕上。

这是 PHP 配置或版本问题吗?

这是在 Windows 10 / IIS 10 机器上。

【问题讨论】:

  • Í 不要认为这是 php 配置或短标签的问题(doc php.net/manual/en/language.basic-syntax.phptags.php),因为 php 结束标签必须是 '?>' 以检查 '=>' 之间的任何空格
  • short_open_tag 已关闭,在 php.ini 中对其进行了更新,现在可以使用:
  • short_open_tag = 开启
  • 非常感谢 - 发表您的评论作为答案,我会将其标记为完成。

标签: php wordpress buddypress


【解决方案1】:

您不允许使用简短的打开标签<?(不鼓励这样做 因为它只有在使用 short_open_tag php.ini 启用时才可用 配置文件指令,或者如果 PHP 配置了 --enable-short-tags 选项)。

参考文档http://php.net/manual/en/language.basic-syntax.phptags.php

【讨论】:

    猜你喜欢
    • 2013-04-13
    • 1970-01-01
    • 1970-01-01
    • 2015-06-10
    • 1970-01-01
    • 2011-04-14
    • 2019-12-15
    • 2012-10-02
    • 1970-01-01
    相关资源
    最近更新 更多