根据参数创建一个打印内容的功能

时间:2016-04-27 19:28:46

标签: php

我想创建一个函数,该参数采用值' on'和'关闭'

public function test(on || off) {
    if isset[test(on);] -> {echo "test";}
    if isset[test(off);] -> {echo "test"; echo "<br>"; echo "great";}
}

最终结果我想成为:

public function test(on || off) {
    if isset[test(on);] -> {function1();}
    if isset[test(off);] -> {function1(); echo "<br>"; function2();}
}

3 个答案:

答案 0 :(得分:0)

请注意,start_seconds = 1461798000000 / 1000.0 start = datetime.datetime.utcfromtimestamp(start_seconds) print('With utc: %s' % start) >>>> With utc: 2016-04-27 23:00:00 start2 = datetime.datetime.fromtimestamp(start_seconds) print('Without utc: %s' % start2) >>>> Without utc: 2016-04-27 23:00:00 用于标识是否定义了变量或数组元素。另请注意,isset()on未在PHP中预定义。

我可以翻译伪代码显示的最佳方式是:

off

答案 1 :(得分:0)

你的功能可以是这样的:

 nicStats5 <-tbl(centralstats, "nicStats5")    

答案 2 :(得分:0)

define("ON",1);
define("OFF",0);
//from here you can use ON or OFF in your program

function test($param = OFF) { //default state if not supplied will be OFF
if($param == ON){
    function1();
}else{
    function1();
    echo "<br>";
    function2();
}
}

test(ON); //will callfunction 1
test(OFF); // will call function1 echo br call function 2