该变量在函数内不可访问。当我在函数外回显变量时,我得到了正确的结果。当我在函数内回显/使用变量时,我得到一个“注意:未定义变量:/setup.php 中的 crLocalIncompleteStatus 35”
有任何想法吗?
<?php
global $wpdb;
$table_name = $wpdb->prefix . 'crLocal';
$crLocalIncompleteStatus = '';
$crLocalCompleteStatus = '';
$crLocal_DBChecked = $wpdb->get_var("SELECT COUNT(*) FROM $table_name");
function crLocal_CheckDB() {
global $crLocal_DBChecked, $crLocalIncompleteStatus, $crLocalCompleteStatus;
if ($crLocal_DBChecked == '0') {
$crLocalIncompleteStatus = 'block' ;
$crLocalCompleteStatus = 'none' ;
} elseif ($crLocal_DBChecked != '0') {
$crLocalIncompleteStatus = 'none' ;
$crLocalCompleteStatus = 'block' ;
} else {
// Broken
// More Code to follow
}
echo $crLocal_DBChecked;
}
crLocal_CheckDB();
$crLocalInstallIncomplete = '<div id="crLocalInstallIncomplete" style="display: '.$crLocalIncompleteStatus.';">' ;
$crLocalInstallComplete = '<div id="crLocalInstallComplete" style="display: '.$crLocalCompleteStatus.';">' ;
?>
所以我需要:
当数据库中的计数为 0 时,$crLocalIncompleteStatus 为 'block',大于 0 时为 'none'。
当数据库中的计数为 0 时,$crLocalCompleteStatus 为 'none',大于 0 时为 'block'。
一只斗牛犬