I want to develop something like my own framework for further websites, there is an existent answered question about my queries but i would like someone to help me so there is
frameworkclass.php
class Framework{
public function hello(){
echo "Hello World!";
}
anotherclass.php
class New extends Framework{
$hellomessage = self::hello();
}
Well I know that I have to type parent::hello()
to call the hello function from Framework class but how can i do it without typing everytime parent::
I don't know maybe something like this $Framework->anyfunction()
?
Another thing that I don't understand about oop is whats the difference about a static
variable and other types
, or between public
protected
or private
functions ? What is a framework auto load function and whats the difference about the caching system of a framework and a framework based on sessions ? Thanks!
You can't initialise a property with a method.
class Framework {
public function hello() {
return "Hello World!";
}
}
class New extends Framework {
public $hellomessage;
public function __construct() {
$this->hellomessage = parent::hello();
}
}
Public means the variable or function can be accessed from anywhere outside of the class.
Protected means the variable or function is only available to the class, and its child classes ( the classes that 'extend' it).
Private means the variable or function is only available to the class itself, and not even the child classes that extend it.
I hope this is helpful.