Reputation: 857
<?php
class TrimPHP_Strings {
public $str;
public function Apply() {
return $this->str;
}
function __constructor($str) {
$this->str = $str;
}
}
function Strings($str) {
$obj = new TrimPHP_Strings($str);
return $obj;
}
?>
<?php
echo Strings("My String")->Apply();
?>
I can not understand why the above code doesn't work? I expect it to output My String
but it simply outputs a blank page.
Upvotes: 1
Views: 107
Reputation: 22773
The proper name for the constructor is __construct
, not __constructor
Upvotes: 11