Yohanne Posted July 8, 2013 Share Posted July 8, 2013 Hi Coders, I have four or more files that load into one file, like below. one.php <?php class one { public function One() { ..... } } ?> one_one.php <?php class one { public function One_one() { ..... } } ?> two.php require_once 'one.php'; require_once 'one_one.php'; and any good idea how to call a class parameter from a one.php and one_one.php files which is only two.php file that i call here three.php <?php require_once 'two.php'; class all { public function __construc() { $x = new One(); } } any good example. ? Link to comment https://forums.phpfreaks.com/topic/279953-calling-class-into-other-class-file/ Share on other sites More sharing options...
trq Posted July 8, 2013 Share Posted July 8, 2013 Pardon? Link to comment https://forums.phpfreaks.com/topic/279953-calling-class-into-other-class-file/#findComment-1439895 Share on other sites More sharing options...
Strider64 Posted July 8, 2013 Share Posted July 8, 2013 // Autoload classes from "classes" directory: function class_loader($class) { require('classes/' . $class . '.php'); } spl_autoload_register('class_loader'); http://us1.php.net/manual/en/function.autoload.php Link to comment https://forums.phpfreaks.com/topic/279953-calling-class-into-other-class-file/#findComment-1439903 Share on other sites More sharing options...
Yohanne Posted July 9, 2013 Author Share Posted July 9, 2013 @Strider64 it is what im looking. and more question. ./myClass.php <?php class myClass { public function __construct() { echo "myClass init'ed successfuly!!!"; } } ?> ./index.php <?php // we've writen this code where we need function __autoload($classname) { $filename = "./". $classname .".php"; include_once($filename); } // we've called a class *** $obj = new myClass(); ?> i dont really get the function of this variable "$filename" and "$classname". i found out that there is no value. could you explain the two variable. Link to comment https://forums.phpfreaks.com/topic/279953-calling-class-into-other-class-file/#findComment-1439992 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.