/**
 * @param WindConnection $connection   WindConnection对象
 * @param string $query  预定义语句
 */
public function __construct($connection = null, $query = '') {
$connection && $this->_connection = $connection;
$query && $this->setQueryString($query);
}什么意思?$connection && $this->_connection = $connection;

解决方案 »

  1.   

    你肯定知道 
    if( $connection && $this->_connection = $connection )
    当 && 前的表达式结果为true时,则需要执行第二个表达式来确定条件成立
    但当 $connection 为false时,就没有必要执行第二个表示了,因为条件已经确立为不成立
      

  2.   

    不好意思我还是没看明白,一个方法内只有一个true或者false ,判断了一下是真还是假,就完事了,什么都没处理,那么这个函数干什么用
      

  3.   

    $connection && $this->_connection = $connection;
    等价于
    if($connection){
          $this->_connection = $connection;
    }
      

  4.   

    这个也算短路写法,有些人叫偷懒写法……简单说,&&前为False的话,&&后的部分程序就不理会了
      

  5.   

    这样看可能清晰点 
    $connection && $this->_connection = $connection;!empty($connection) && $this->_connection = $connection;相当于
    if(!empty($connection))$this->_connection = $connection;
      

  6.   

    $connection = null, $query = ''
    为什么一个定义成空,一个定义成 null,有什么区别吗
      

  7.   

    这种写法是从shell里copy来的。shell经常这么写:test -f /home/xxx/myfile && rm -f myfile