How can public functions from a parent class be accessed and utilized in extended classes in PHP?
To access and utilize public functions from a parent class in extended classes in PHP, you can simply use the `parent::` keyword followed by the function name to call the parent class function within the child class.
class ParentClass {
public function parentFunction() {
return "This is a function from the parent class.";
}
}
class ChildClass extends ParentClass {
public function childFunction() {
return parent::parentFunction();
}
}
$child = new ChildClass();
echo $child->childFunction(); // Output: This is a function from the parent class.