class MyController { public function index() { echo "Hello, world!"; } } $controller = new MyController(); $controller->index();
class MyController { public function index($name) { echo "Hello, $name!"; } } $controller = new MyController(); $controller->index("Alice");In this example, the Controller init function is used to create a new instance of the MyController class, and then the index method of that class is called with the argument "Alice". This causes the method to output "Hello, Alice!" to the browser. Package/Library: The Controller init function is commonly used in PHP web development frameworks such as Laravel, CodeIgniter, and Symfony. It is part of the core functionality of these frameworks and is typically provided as part of a larger package or library of functions and classes.