I have done lots of class in C++ which is a very long time ago. I have never attempted this in php. Here is what I was looking at. Please not too crital over this but I am interested in pulic and private variables and functions here. Do need to give values to the variables in the class?
This is what I have devloped so far. Thanks for any help.
<?php
Class Human
{
public string $Name ="";
public float $Height = 0.0;
public int $Age = 0;
private string $Detals;
public function __construct(float $Heiht, int $Age, string $Name = "Billy")
{
$this->Height = $Height;
$this->Age = $Age;
$this->Name = $Name;
}
function __destruct()
{
// nothing to see here
}
public function WhoAmI(): string
{
$Details = "Name:" . $Name . " Height:" . $Height . " Age:" . $Age;
return $this->Details;
}
}
$PersonA = new Human;
$PersonA->$Name = "Philip";
$PersonA->$Height = 5.10;
$PersonA->$Age = 24;
echo $PersonA->WhoAmI;
$PersonB = new Human(5.10, 52);
echo $PersonB->WhoAmI // Name will be Billy
?>