I understand how it works but why would we practically use this?
__String helps us it returning error message in case there is some error in constructor.
Following dummy code will clarify it better. Here if creation of object is failed, an error string is sent:
class Human{
private $fatherHuman;
private $errorMessage ="";
function __construct($father){
$errorMessage = $this->fatherHuman($father);
}
function fatherHuman($father){
if($father qualified to be father){
$fatherHuman = $father;
return "Object Created";//You can have more detailed string info on the created object like "This guy is son of $fatherHuman->name"
} else {
return "DNA failed to match :P";
}
}
}
function run(){
if(ctype_alpha($Rahul = Human(KingKong)){
echo $Rahul;
}
}
run(); // displays DNA failed to match :P