0

所以这是我的问题;我正在处理其他团队成员交给我的一些代码(不是我的代码);因此,要弄清楚所有变量和此类匹配的位置非常深入且乏味,我设法找出了这篇文章,这给我带来了麻烦,为什么我的代码在这里不起作用

<td nowrap style="border-left: 1px solid #dddddd;" align="center">&nbsp;&nbsp;

                     <?=$display_balance_details;?>

这段代码显然将其设置为 $display_balance_details 仅在某些页面上设置,我的问题是我试图将其移至所有网页的标题;

    else if ($section == 'history')
    {
        $user = new user();
        $user->setts = &$setts;

        $row_user = $db->get_sql_row("SELECT * FROM
            " . DB_PREFIX . "users WHERE user_id=" . $session->value('user_id'));

        $template->set('user_details', $row_user);

        $template->set('display_account_status', $user->account_status($row_user['active'], $row_user['approved']));

        $user_payment_mode = $fees->user_payment_mode($session->value('user_id'));
        $template->set('user_payment_mode', $user_payment_mode);

        $template->set('display_payment_mode', $user->payment_mode_desc($user_payment_mode));

        (string) $display_balance_details = null;
        $display_balance_details = $user->show_balance($row_user['balance'], $setts['currency']);

        if ($user_payment_mode == 2 && $row_user['balance']>=$setts['min_invoice_value'])
        {
            $display_balance_details .= ' [ <a href="fee_payment.php?do=clear_balance">' . MSG_CLEAR_ACC_BALANCE . '</a> ]';
        }

        $template->set('display_balance_details', $display_balance_details);

        $show_history_table = false;

这段代码告诉在哪些页面上设置它

<? } else if ($page == 'account') { ?>
<td nowrap <?=(($section == 'history') ? 'class="subcell_a"' : 'class="subcell_u"');?>><a href="<?=process_link('members_area', array('page' => 'account', 'section' => 'history'));?>">

所以我的问题是如何在不删除 $section == 'history' 位的情况下设置 $display_balance_details (因为这可能会导致一系列其他问题,不确定代码是如何编写的)以及如何最好地解决这个问题?

4

1 回答 1

0

您可以使变量全局:

global $display_balance_details;

或者您在以下情况之前声明 $display_balance_details:

(string) $display_balance_details = null;
if ($section == 'history')
{
your code
}
于 2012-07-26T21:59:55.627 回答