我剛換了一堆WordPress的託管網站的服務器。在舊的服務器上,我們有5.3版本的PHP,在新的版本上有5.4.33。問題是我們在這次改變後收到很多錯誤,並且有些錯誤對我來說很難解決。看看下面的代碼,請:)從php 5.3升級到5.4.33後wordpress主題錯誤
這是我得到的錯誤:
注意:未定義的變量:在/可溼性粉劑內容圖標/主題/比分/庫/職能 - 上線單match.php 138
說明:未定義變量:在圖像上/wp-content/themes/livescore/library/functions-single-match.php管線145
說明:未定義變量:在/wp-content/themes/livescore/library/functions-single-match.php圖標上線179
說明:未定義變量:圖像/可溼性粉劑內容/主題/比分/庫/函數單match.php上線184
這是下面的功能單match.php:
<?php
function lastMatches($teamName, $directTeam = '')
{
global $wpdb_mysqli;
$matches = array();
if ($directTeam)
{
$args = array(
'post_type' => 'matches',
'post_status' => 'publish',
'posts_per_page' => 10,
'meta_query' => array(
array(
'key' => '_live_echipa_gazda',
'value' => $directTeam,
'compare' => '='
),
array(
'key' => '_live_echipa_oaspete',
'value' => $teamName,
'compare' => '='
)
)
);
}
else
{
$args = array(
'post_type' => 'matches',
'post_status' => 'publish',
'posts_per_page' => 10,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => '_live_echipa_gazda',
'value' => $teamName,
'compare' => '='
),
array(
'key' => '_live_echipa_oaspete',
'value' => $teamName,
'compare' => '='
),
)
);
}
$query = new WP_Query($args);
$matches = $query->posts;
return $matches;
}
function matchStatusGazde($matchID)
{
$statusIstoric = get_post_meta($matchID, '_live_status_meci_gazde', true);
$result = new stdClass();
switch ($statusIstoric)
{
case 'v':
$icon = 'smileyface1.png';
break;
case 'e':
$icon = 'smileyface3.png';
break;
case 'i':
$icon = 'smileyface2.png';
default:
break;
}
if ($icon)
{
$pathImg = get_stylesheet_directory_uri() . "/library/images/$icon";
$image = "<img src='$pathImg' border='0'/>";
}
$result->image = $image;
return $result;
}
function matchStatusOaspeti($matchID)
{
$statusIstoric = get_post_meta($matchID, '_live_status_meci_oaspeti', true);
$result = new stdClass();
switch ($statusIstoric)
{
case 'v':
$icon = 'smileyface1.png';
break;
case 'e':
$icon = 'smileyface3.png';
break;
case 'i':
$icon = 'smileyface2.png';
default:
break;
}
if ($icon)
{
$pathImg = get_stylesheet_directory_uri() . "/library/images/$icon";
$image = "<img src='$pathImg' border='0'/>";
}
$result->image = $image;
return $result;
}
感謝特里斯坦你的代碼更改值,不幸的是,問題是,我不能追查錯誤。在wordpress中,你可以通過添加define('WP_DEBUG',false)來隱藏所有的通知。在wp-config.php這裏的問題是,代碼不生成$ image變量,我正在尋找解決方案,不隱藏通知:) – AXLwarrior
@AXLwarrior:那麼你應該問這個問題。 Tristan的文章對你提出的問題是一個完美的答案。 – lxg
我編輯過,以顯示如何解決未定義的變量 – Tristan