我有一个问题,我有一个bm_products_filter
无法从我的 index.php 文件中看到变量的类。
我有 2 个文件:index.php 和 bm_products_filters.php
我在 index.php 中有一个查询,我想在 bm_products_filters.php 中回显它
(这里有一些数据库函数(它们正在工作,因为我可以正确地回显 index.php 中的变量)
$product_count .= "SELECT COUNT(p.products_id) as total
from
" . TABLE_PRODUCTS . " p
left join " . TABLE_SPECIALS . " s
on p.products_id = s.products_id
left join " . TABLE_MANUFACTURERS . " m
on p.manufacturers_id = m.manufacturers_id
join " . TABLE_PRODUCTS_DESCRIPTION . " pd
on p.products_id = pd.products_id
join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c
on p.products_id = p2c.products_id
where
p.products_status = '1'
and pd.language_id = '" . (int) $languages_id . "'
and p2c.categories_id = '" . (int)$current_category_id . "'";
$product_count_query = tep_db_query($product_count);
$product_count_tally = tep_db_fetch_array($product_count_query);
global $test_me;
$test_me = $product_count_tally['total'];
?>
我试图回显的变量是$test_me
.
该类bm_products_filter
是从 index.php 中调用的(我猜是间接的),如下所示:
<?php echo $oscTemplate->getBlocks('boxes_column_left'); ?>
该getBlocks
函数查看文件夹“boxes”中的所有 PHP 文件,并找到用于左列的那些文件(bm_products_filters.php 就像它所显示的那样)。
现在这是我完全错误的地方,但我不知道该怎么做。
在 bm_products_filters.php 我只是想做:
echo $test_me;
但我什么也没得到。我认为宣布它global
可能会起作用,但那不起作用。我想我需要以某种方式调用它->
不过,我真的不太了解范围。
希望我在这里提供了足够的信息?让我知道它是否需要更多。
更新:
这是我试图做的,但它不起作用:
//index.php
$product_count .= "SELECT COUNT(p.products_id) as total
from
" . TABLE_PRODUCTS . " p
left join " . TABLE_SPECIALS . " s
on p.products_id = s.products_id
left join " . TABLE_MANUFACTURERS . " m
on p.manufacturers_id = m.manufacturers_id
join " . TABLE_PRODUCTS_DESCRIPTION . " pd
on p.products_id = pd.products_id
join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c
on p.products_id = p2c.products_id
where
p.products_status = '1'
and pd.language_id = '" . (int) $languages_id . "'
and p2c.categories_id = '" . (int)$current_category_id . "'";
$product_count_query = tep_db_query($product_count);
$product_count_tally = tep_db_fetch_array($product_count_query);
$test_me = $product_count_tally['total'];
function product_filter_count() {
global $test_me;
return $test_me;
}
//bm_products_filter.php
echo product_filter_count();
我收到未定义函数错误的调用。如果我在 index.php 中回显该函数,它就可以工作。为什么从其他功能中看不到它?