include - __DIR__ and autoloading php -


i don't know if problem in autoloading, having problem, here code:

index.php

require __dir__ . '/app/autoload.php'; 

folder structure:

index.php app/ --autoload.php 

autoload.php

 function autoloader($classname) {     // list directories autoload classes     $paths = array(         __dir__ . '/system/',         __dir__ . '/app/models/',         __dir__ . '/app/dao/'     );     foreach($paths $path) {         $file = $path . '/' . $classname . '.php';         if (is_file($file))             include $file;     } } 

for reason doesn't work do:

__dir__ . '../system/ ... et al. 

dir in autoload file refer /app.

try:

function autoloader($classname) {     // list directories autoload classes     $paths = array(         '../system/',         '/models/',         '/dao/'     );     foreach($paths $path) {         $file = $path . '/' . $classname . '.php';         if (is_file($file))             require_once $file;     } } 

if fails start echoing out paths , dir see if referenced properly.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -