default method argument with class property?

AvnerEliyahuR

New Member
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' is defaulted an settable elsewhere in the class. I have a method where I want to have it settable again, but not override the existing value. I get an error when I try this:\[code\]public function place( $path, $overwrite = $this->blnOverwrite ) { ... }\[/code\]Must I do something like this?\[code\]public function place( $path, $overwrite = NULL ) { if ( ! is_null($overwrite) ) { $this->blnOverwrite = $overwrite; } ...}\[/code\]
 
Back
Top