<?php class ren{ //定义人类 //定义成员属性 private $name='Tom'; private $age=15; //定义成员方法 public function getname(){ return $this->name; } public function getage(){ return $this->age; } //定义__get()魔术方法 public function __get($name){ $method="get{$name}
一句话判断 [ ! $a ] && echo "a is null" 1.判断变量 read -p "input a word :" word if [ ! -n "$word" ] ;then echo "you have not input a word!" else echo "the word you input is $word" fi 或者 #!/bin/sh a= if [ !
#!/bin/bash argv=" if [ -z "$argv" ] then echo "argv is empty" else echo "argv is not empty" 说明,-z选项判断一个变量是否为空,如果为空则执行then部分,如果不为空,则执行else部分. 另外,在shell中建议给变量加上双引号,比如如果test的内容是argv="adsf adf 1234e"有空格,变量不加双引号执行i