PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Sebastian Potasiak  >  PHP Autoloading with namespaces  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example of using loader
Class: PHP Autoloading with namespaces
Load classes mapping namespaces to directories
Author: By
Last change:
Date: 10 years ago
Size: 525 bytes


Class file image Download

// include loader class - it's necessary :(
require_once 'classes/Loader.php';

// create new loader instance
$loader = new Loader();

// set loader's include paths, files extensions and register it
$loader ->setIncludePath('classes/')

// create new \MyPackage\Test instance (autoloading works! :D)
$test = new \MyPackage\Test();

// do something with an example class
$test->setText('This is an example string.');

For more information send a message to info at phpclasses dot org.