Back to getting up to speed on PHP. This is a quick snippet of code that’ll probably come in handy: –

<?php
spl_autoload_register(function ($class_name) {
    include $class_name . '.php';
});

$obj  = new MyClass1();
$obj2 = new MyClass2(); 
?>

This will auto-load a php file with the class name requested when the class is used. Assuming the naming standard is followed correctly this will be a handy little shortcut

 

 

 


Discover more from

Subscribe to get the latest posts sent to your email.

Leave a comment

Trending