Jump to content

calling class into other class file


Go to solution Solved by 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

  • Solution

@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 by jayson_ph
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.