Php Autoload Example - Php

How to call autoload() php?

Snippet Code


  
Rate this page :
  [ 0 votes]

Autoloader is a magic method in php which calls automatically when we try to create an object on the class and if the class in the script is not found by php engine then it will call autoload magic method.

<?php function __autoload($className) { include $className . '.php'; } $customClass = new democlass; $result = $customClass->demo('Hscripts'); ?> democlass.php: ------------------ <?php class democlass { function demo($test) { echo "Your test string is : ".$test; } } ?>

Tags


Ask Questions

Ask Question