Jump to content

Class inside a class


Drezard

Recommended Posts

Okay so, I have something along the lines of this:

 

fileA.php:

<?php

class A {

    function p() {

        echo 'Home';

    }

}

?>

 

fileB.php:

<?php
include('fileA.php');

class B {

    function S() {

        $A->p();

    }

}


?>

 

Okay, so thats the basic theory behind my code. But, its alot more complex in the functions. But, I want to call a function from Class A, in Class B. How would I declare Class A, so it could be used in Class B? Like a:

 

public $A = new A;

 

But, that doesn't work.

 

Daniel

Link to comment
https://forums.phpfreaks.com/topic/87368-class-inside-a-class/
Share on other sites

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.