- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在我的 WordPress 网站上运行一些 PHP 代码,当 PHP 运行以回显某些信息时,它没有在正确的位置回显。代码的缩写版本是:
<div class="description cms">
<div id="home_left_middle">
<h2>Search By Category</h2>
[xyz-ips snippet="Category-List"]
</div>
</div>
短代码用于插件 XYZ PHP 代码,它基本上只是一种在 WordPress 帖子中使用“包含”的方法。我已经在 WP 数据库中设置了一些自定义,但这只是基本的数据库调用。所有信息都从数据库成功返回,因此没有问题。我在那里使用的 PHP 代码是:
$sql = "SELECT * FROM wp_categories_table";
$result = $wpdb->get_results($sql);
echo "<ul class='category_list'>";
foreach( $result as $results ) {
$category = $results->category;
$number = $results->number_of;
$category_html = htmlentities($category);
echo "<li><a href='?search-class=DB_CustomSearch_Widget-db_customsearch_widget&widget_number=preset-default&cs-all-0=&cs-post_cat-1=".$category_html."&search=Search'>".$category." (".$number.")</a></li>";
}
echo "</ul>";
发生的情况是,当 PHP 代码运行时,它会在 div.description 之后(在 div#home_left_middle 之前)立即回显它,并且只有 H2 保留在 home_left_middle div 中。那不是运行代码的地方。
奇怪的是,我在另一个站点上使用了完全相同的代码(我复制了这个站点,因为我们只是在更换服务器,但内容完全相同)并且它在另一个服务器上运行良好。这是一个 VPS,所以我想知道是否有某种我没有正确安装在服务器上的 PHP 扩展可能会导致这种情况?我知道这有点牵强,但我很困惑为什么在相同版本的 WordPress 中使用完全相同的代码并使用相同的主题和 CSS 文件会在两个不同的站点上导致不同的结果。我看到的唯一区别可能是服务器,除非我忽略了一些小错误?
对于那些询问输出缓冲问题的人,我最近从上一个服务器复制了 php.ini 文件,输出缓冲代码如下所示:
; output_buffering
; Default Value: Off
; Development Value: 4096
; Production Value: 4096
所以它似乎被注释掉了。
最佳答案
就像评论中建议的 maioran84,这可能是输出缓冲区的一些问题。我建议您将 php.ini 文件从工作站点复制到非工作站点服务器。
查看 PHP 配置文件,有一些设置可能会导致输出在 wordpress 准备好之前显示。
; Implicit flush tells PHP to tell the output layer to flush itself
; automatically after every output block. This is equivalent to calling the
; PHP function flush() after each and every call to print() or echo() and each
; and every HTML block. Turning this option on has serious performance
; implications and is generally recommended for debugging purposes only.
; http://php.net/implicit-flush
; Note: This directive is hardcoded to On for the CLI SAPI
implicit_flush = Off
output_buffering = 4096
查看 add_shortcode()
的 WordPress 文档,以下文本 block 确实很突出。您可以轻松更改所有 echo
语句以将值附加到字符串,然后将整个字符串返回。
Note that the function called by the shortcode should never produce output of any kind. Shortcode functions should return the text that is to be used to replace the shortcode. Producing the output directly will lead to unexpected results. This is similar to the way filter functions should behave, in that they should not produce expected side effects from the call, since you cannot control when and where they are called from.
https://codex.wordpress.org/Function_Reference/add_shortcode
希望这能帮助您解决这个问题,但我以前从未听说过发生过这样的错误。
关于PHP 没有在正确的地方回显,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22467912/
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
操作无法完成。 Places API 库中发生内部错误。如果您认为此错误代表错误,请使用我们社区和支持页面 (https://developers.google.com/places/support)
我正在尝试在我的项目中使用 google places,我将其设置在 fragment 中而不是 Activity 中,我的自动完成 fragment 在 fragment 中。但是,当我尝试搜索它时
我的目的是使用R来查询google api。 我有一个地址和名称列表(属于商店、餐馆等),我需要为每个地址和名称存储: “纬度”、“经度”、“业务类型” 我的想法是使用 google place ap
我正在寻找设置一个自动完成的谷歌地方小部件。 我有一个带有“searchFieldText”id 的输入类型文本。 这是我的 JS 代码: var inputsec = document.getEle
是否可以使用图形 API(或地址/ zip )按纬度/经度和半径获取地点?我在文档中的任何地方都看不到它 最佳答案 搜索 URL 的以下格式将返回某个位置附近的地点列表: https://graph.
我正在探索 Google API,主要是 Places API。由于对 Google Places API 的请求数限制为 100,000,因此我正在寻找方法来最大限度地减少发送到 API 的请求数。
伙计们,我在我的应用程序中有一个功能,可以使用 GetFiles 在特定目录中搜索特定文件。方法 System.IO.Directory.GetFiles(string path, string
我已经在 Laravel 5.3 上使用 where 查询成功创建了许多函数,但是这次发生了一些奇怪的事情。 public function show($id){ $artikel = Art
我正在为我的 iPhone 应用程序使用 Facebook 图形 API 来获取附近地点的列表,我使用带有一些参数的“搜索”请求。我得到的响应是一个包含以下信息的地点列表:“纬度”、“经度”、“名称”
我有一个 Android 应用程序,我在其中使用 Google map 显示附近的地方,如加油站、药店等。我正在使用 map 和地点 API。 https://maps.googleapis.com/
我是一名优秀的程序员,十分优秀!