Can I set up a default method argument with class property in PHP?

前端 未结 4 1381
离开以前
离开以前 2020-12-18 21:19

I\'m using PHP 5.2.6. I want to have a default value for an argument in a method, but it seems I\'m getting a bit too clever.

The class property blnOverwrite

4条回答
  •  不思量自难忘°
    2020-12-18 21:54

    you just can shorten it a little:

    public function place( $path, $overwrite = NULL ) { 
        if(!is_null($overwrite))$this->blnOverwrite = $overwrite;
        ...
    }
    

    but thats nearly the same

提交回复
热议问题