autoloading classes
improved version :
<?php
spl_autoload_register(function($className) {
$file = __DIR__ . '\\' . $className . '.php';
$file = str_replace('\\', DIRECTORY_SEPARATOR, $file);
if (file_exists($file)) {
include $file;
}
});inside root directory create a autoloader.php file and add the following code :
------------------------------------------------------------------------------
<?php
spl_autoload_register(function($className) {
$file = $className . '.php';
if (file_exists($file)) {
include $file;
}
});
inside your usage file :
--------------------------
<?php
include 'autoload.php';
$circle = new Circle;
$square = new Square;
Also in PHP:
- change time format php
- file_get_contents(): SSL operation failed with code 1. jpeg
- currentdate function in php
- clear firebase cacheweb hosting
- How to display MySQL data dynamically using jQuery and PHP
- codeigniter 4 login example
- create new project laravel step by step
- date show year first php
- ->format() php
- $date php
- change header location in php
- date from format php
- db seeder laravel 5
- @ in php db connect
- 10 digit random number generator php
- centos search directory php.exe
- convert matrix row to column php
- add item to array in php
- find largest element of an array in php
- client's ip address in php
- codeigniter get last insert id
- check key exists in array in php
- data php format
- Activate errors tracking in your script using the ini_set() function