php magic class inclusion - solved

  • Bozebo
  • Expert
  • Expert
  • User avatar
  • Posts: 709
  • Loc: 404

Post 3+ Months Ago

Solved
Hi, I am sure there is a shorthand way to include classes from a directory that involves a magic function, I have googled the topic but I can't find any info on it.

Does anybody know what it is? I remember using it before and it took a path which the classes are held in, the idea is whenever I use new [classname]; it includes it from [path]/[classname].php automatically.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bozebo
  • Expert
  • Expert
  • User avatar
  • Posts: 709
  • Loc: 404

Post 3+ Months Ago

Oops, I found it deep in one of the articles that I thought was junk.

Here it is:
PHP Code: [ Select ]
<?php
function __autoload($class){
$file = $class .'.php';
  if(file_exists($file)){
    require_once($file);
  }
}
?>
 
  1. <?php
  2. function __autoload($class){
  3. $file = $class .'.php';
  4.   if(file_exists($file)){
  5.     require_once($file);
  6.   }
  7. }
  8. ?>
  9.  
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

This isn't something very likely to happen, but something to consider. :)
website-security/tricking-php-autoload-into-loading-other-files-t101250.html

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 94 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.