spl_autoload_register - Php

How to use spl_autoload_register in php?

Snippet Code


  
Rate this page :
  [ 0 votes]

spl_autoload_register() helps you to register multiple functions that PHP will put into a stack/queue and call sequentially when a "new Class" is declared.

<?php spl_autoload_register(function ($class) { include './' . $class . '.php'; }); $obj = new Class1(); ?> Class1.php file: <?php class Class1{ function __construct(){ echo "Test code created"; }} ?>

Tags


Ask Questions

Ask Question