Esempio n. 1
0
     }
     continue;
 }
 // 物流
 if ($rep = is_express($data)) {
     send_qun_msg($v['value']['from_uin'], $rep, $cookie['login']['psessionid'], $cookie['clientid']);
     continue;
 }
 // 学习模式
 if (is_study($data)) {
     send_qun_msg($v['value']['from_uin'], "已进入学习模式.", $cookie['login']['psessionid'], $cookie['clientid']);
     $reply = unserialize(read_file(REPLY));
     continue;
 }
 // 数学
 if (($rep = math($data)) !== NULL) {
     send_qun_msg($v['value']['from_uin'], $rep, $cookie['login']['psessionid'], $cookie['clientid']);
     continue;
 }
 // ip查询
 if ($ip_data = is_ip($data)) {
     send_qun_msg($v['value']['from_uin'], $ip_data, $cookie['login']['psessionid'], $cookie['clientid']);
     continue;
 }
 // 呼叫人工回复
 if ($info = is_call($data)) {
     send_buddy_msg(4092490351, "qun:{$v['value']['from_uin']}--->{$info}", $cookie['login']['psessionid'], $cookie['clientid']);
     continue;
 }
 // 职能取词
 if (($data = is_match($data)) && array_key_exists($data, $reply)) {
Esempio n. 2
0
            case 'eq':
            case 'is':
            default:
                $output = $subject == $operand ? true : false;
                $i++;
                break;
        }
        $eq = $output ? $eq : false;
    }
}
$output = $eq || (!isset($left_part) || !$left_part) && (isset($part_eq) && $part_eq) ? $then : $else;
if (strpos($output, '@TPL:') !== FALSE) {
    $output = $modx->getChunk(str_replace('@TPL:', '', $output));
}
//Может быть стоит вместо eval использовать runSnippet?
//Отдадим на откуп самому modx-у парсинг строки с вызовом сниппета.
//т.е. в @eval мы передаем обызчный вызов сниппета в формате [[snippet? &argv1=`val1` &argv2=`val2`]];
if (substr($output, 0, 6) == "@eval:") {
    //ob_start();
    $output = $modx->evalSnippets(substr($output, 6));
    //$output = ob_get_contents();
    //ob_end_clean();
}
if (empty($then) && empty($else)) {
    if ($math == 'on') {
        $subject = math($subject);
    }
    $output = $subject;
}
unset($is, $then, $else, $output, $opers, $subject, $eq, $operand, $chunk, $part_eq);
return $output;
		for($i=3 ; $i<=$n ; $i++){
		$a = (isset($series[ (int)$i-3 ]))?$series[ (int)$i-3 ]:0;
		$b = (isset($series[ (int)$i-2 ]))?$series[ (int)$i-2 ]:0;
		$c = (isset($series[ (int)$i-1 ]))?$series[ (int)$i-1 ]:0;
		$d = ($a+$b+$c)-1;

			if($d<0){
			$d = 0;
			}
		$series[$i] = $d;
		}
		echo $series[ (int)$n-1 ];
	}
									
	
	fantastic3(35);*/
// Or..............................
function math($n)
{
    $series = array(0, 1, 1);
    for ($i = 0; $i < $n; $i++) {
        $a = $series[$i];
        $b = $series[$i + 1];
        $c = $series[$i + 2];
        $d = $a + $b + $c - 1;
        $series[$i + 3] = $d;
    }
    echo $series[$n - 1];
}
math(18);
Esempio n. 4
0
<?php

$x = 45;
$y = 30;
function math()
{
    global $x, $y;
    $y = $x + $y;
}
math();
echo $y;
Esempio n. 5
0
<?php

// 1.4 Closure function
function math(Closure $type, $first, $second)
{
    return $type($first, $second);
}
$addiction = function ($first, $second) {
    return $first + $second;
};
$substraction = function ($first, $second) {
    return $first - $second;
};
echo math($addiction, 4, 3) . "\n";
function addSubt($value1, $value2)
{
    $add = $value1 + $value2;
    $subt = $value1 - $value2;
    return array($add, $subt);
}
$resultArray = addSubt(10, 4);
echo "Add: " . $resultArray[0] . "\n";
echo "Substr: " . $resultArray[1] . "\n";
list($addResult, $sustrResult) = addSubt(20, 5);
echo "Add: " . $addResult . "\n";
echo "Substr: " . $sustrResult . "\n";
function paint($pet = "doggie", $color = "red")
{
    return "The color for your {$pet} is {$color}. \n";
    // var_dump(debug_backtrace());
}
Esempio n. 6
0
    } elseif ($param1 > $param2) {
        for ($i = $param1; $i >= $param2; $i--) {
            echo $i . " ";
        }
    }
    echo $n;
}
$tag1 = '<p>';
$tag2 = '</p>';
$param1 = 42;
$param2 = 100;
$tagg = '<b>';
$tagg2 = '</b>';
math($tag1, $tag2, $param1, $param2);
math('<h1>', '</h1>', $param1, $param2);
math($tagg, $tagg2, $param1, $param2);
//task05
function new_fun($parameter, $new1, $new2)
{
    echo $new1;
    $sum = 0;
    foreach ($parameter as $key => $value) {
        if ($key % 2 == 0) {
            $sum += $value;
        }
    }
    echo $sum;
    echo $new2;
}
$arr = range(1, 10);
$new1 = '<p>';