Jump to content

calling class into other class file


Yohanne

Recommended Posts

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

@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. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.