Jump to content

Cross class scripting...


WhiteyDude

Recommended Posts

Note: I don't think anyone checks the O.O.P. section... There arn't many posts or reads there... It's fine if someone wants to delete the original topic there :).

 

 

Hi guys,

 

 

I have a quick but relatively urgent question.

 

I have 2 classes here, and I wish to call a function that's inside one of them from another.

 

Example code:

 

 

Main page:

<?php
$class1 = new Class1();

$class2 = new Class2();

$class1->function1();
?>

 

Class 1

<?php
class Class1 {
    function Class1() {}

    function function1()
    {
        //THIS is the line I'm having a problem with
        Class2::class2function();
    }

}
?>

 

Class 2

<?php
class Class2 {
    function Class2() {}

    function class2function()
    {
         echo "Worked!";
    }
}
?>

 

 

Another problem is that on the apache server I'm running (2.2.4, local) I'm unable to display PHP errors. I've tried everything I can think of - the PHP ini is starting to get worn, it's been modified so many times. PHP 5.2.1 by the way.

 

 

Please help guys, I need this fixed within the next hour or so.

 

 

Thanks,

 

 

 

 

/Whitey

Link to comment
https://forums.phpfreaks.com/topic/45378-cross-class-scripting/
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.