note 104187 modified in language.oop5.autoload by danbrown

From: Date: Fri, 03 Jun 2011 16:16:51 +0000
Subject: note 104187 modified in language.oop5.autoload by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-180234@lists.php.net to get a copy of this message
in my case i use config.php and put all the settings there including the _autoload functions. Just include the config.php in all of your php file. Heres how: config.php: <?php function __autoload($classname) { include_once("classfolder/" . $classname . ".php"); } ?> ClassFolder: with SampleClass.php <?php class SampleClass { public function hello_rahj() { echo "Hello rahj!"; } } ?> In your Typical Php File: e.g. Index.php <?php include("config.php") $hello = new SampleClass(); $hello->hello_rahj(); // outputs Hello rahj! ?> When using the _autoload functions, Make Sure you use a Proper naming Convention. Hope this Helps! --was-- in my case i use config.php and put all the settings there including the _autoload functions. Just include the config.php in all of your php file. Heres how: config.php: <?php function _autoload($classname) { include_once("classfolder/" . $classname . ".php"); } ?> ClassFolder: with SampleClass.php <?php class SampleClass { public function hello_rahj() { echo "Hello rahj!"; } } ?> In your Typical Php File: e.g. Index.php <?php include("config.php") $hello = new SampleClass(); $hello->hello_rahj(); // outputs Hello rahj! ?> When using the _autoload functions, Make Sure you use a Proper naming Convention. Hope this Helps! http://php.net/manual/en/language.oop5.autoload.php

« previous php.notes (#180234) next »