I have been reading over the manuals of a verity of different methods that can be used in a OOP Style development zone.
class Class{
private function SortArrayByNoExample (){
$ExampleArray = array ('Item_1', 'Item_3','Item_6','Item_5','Item_4','Item_2');
Echo "Original Array: <br>";
print_r($ExampleArray);
Echo "<br><br><br>";
echo "Sorted Array";
natsort($ExampleArray);
print_r($ExampleArray);
}
public function NaturalSort ($Arg1){
if (!is_array($Arg1)){
$this->SortArrayByNoExample();
}else{
natsort($Arg1);
return $Arg1;
}
}
I have this current scenario, take this as an example.
I understand public functions can be accessed by:
$Foo = new Class();
$Foo->PublicFunctionName();
and Private function can only be accessed from within the class.
public function NaturalSort ($Arg1){
if (!is_array($Arg1)){
$this->SortArrayByNoExample();
}
If these function perfectly on their own, why is their such methods as:
Abstract
, static
, protected
.
Then there is extensions such as:
class AnotherClass extends Class {}
^^ Why have this? Why can't you include the functions inside your original class.
My Overall question, is why would I use Abstract
, Static
, Protected
, and extends
?