Exemplo n.º 1
0
<?php

define('IN_ECS', true);
define('LIMIT_NUM', 8);
require dirname(__FILE__) . '/includes/init.php';
require_once ROOT_PATH . '/includes/lib_common.php';
require_once ROOT_PATH . '/includes/cls_template.php';
if ((DEBUG_MODE & 2) != 2) {
    //$smarty->caching = true;
}
$cache_id = sprintf('%X', crc32('newyear' . '-' . $_CFG['lang']));
if (!$smarty->is_cached('newyear.dwt', $cache_id)) {
    $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('favourable_activity') . " where act_name like '周年庆%' ORDER BY sort_order DESC LIMIT 2";
    $newyearActivty = $GLOBALS['db']->getAll($sql);
    foreach ($newyearActivty as $key => $val) {
        $goods = getGoods(array('firterType' => $val['act_range'], 'firterVal' => $val['act_range_ext']));
        setSomeGoodsValue($goods, array('discountType' => $val['act_type'], 'discountVal' => $val['act_type_ext']));
        $newyearActivty[$key]['goods'] = $goods;
    }
    assign_template();
    $smarty->assign('keywords', htmlspecialchars($_CFG['shop_keywords']));
    $smarty->assign('description', htmlspecialchars($_CFG['shop_desc']));
    $smarty->assign('categories', get_categories_tree(0));
    // 分类树
    $smarty->assign('newyearActivty', $newyearActivty);
}
$smarty->display('newyear.dwt', $cache_id);
function setSomeGoodsValue(&$goods, $dsct)
{
    $dsct['discountVal'] = floatval($dsct['discountVal']);
    if ($dsct['discountType'] == 2) {
Exemplo n.º 2
0
    //любой код за return никогда не будет выполнен, так как после выполнения return выполнение кода обывается
}
$test = [1, 2, 8, 9, 7, 6, 5, 4, 3];
echo myCount($test);
#################################### гипотетическая ситуация ####################
function getGoods()
{
    if (connect == true) {
        // если конект с базой произошел - вернуть массив
        return $arrGoods;
    } else {
        return false;
        // если нет, то  вернуть - false
    }
}
echo getGoods();
##################################### функция, которая возводит число в степень ###############
function myPow($numb, $scale)
{
    $result = 1;
    if ($scale >= 0) {
        for ($i = $scale; $i > 0; $i--) {
            $result *= $numb;
        }
    } else {
        for ($i = $scale; $i < 0; $i++) {
            $result *= $numb;
        }
        $result = 1 / $result;
    }
    return $result;