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. ? Quote 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? Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/279953-calling-class-into-other-class-file/#findComment-1439903 Share on other sites More sharing options...
Solution Yohanne Posted July 9, 2013 Author Solution Share Posted July 9, 2013 (edited) @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. Edited July 9, 2013 by jayson_ph Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.