2

Hi I have a class as follows:

<?php
include '(OrderContainer.php)';
class OrderAuthenticator
{
     private $OrderObj;
     public function __construct($Order)
    {
        $this->OrderObj = $Order;
         echo 'Created an instance os OrderContainer<br/>';
    }

    //Misc methods.....


}
?>

Then I have a method that tries to instantiate this object

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

$Authenticator = new OrderAuthenticator($OrderObj);

?>

Problem is that in the object is not instantiated..... No matter what I do ..... Im new to PHP so I was wondering if there is something quite obvious here that Im not doing?

Could someone please give me a hand.. Thanks

3
  • $OrderObj is undefined. Where is this coming from? Commented Jul 24, 2011 at 18:47
  • No I dont see any errors. $OrderObj is a a variable to hold an instance of $OrderContainer that is passed to the constructor. Commented Jul 24, 2011 at 20:04
  • Sorry for the confusion. $OrderObj is defined earlier in the code, I didn't bother to write the whole file. But, It is instantiated earlier. Commented Jul 24, 2011 at 20:07

3 Answers 3

3

It seems as include '(OrderContainer.php)'; should be include('OrderContainer.php'); instead.

Make sure $OrderObj is defined in the main script creating an instance of OrderAuthenticator.

To debug, be sure that PHP is showing error messages by starting with error_reporting(E_ALL); ini_set('display_errors',1); first in the main script.

Also, make sure you have no syntax error (for example, by printing "Hello world" in your script).

Sign up to request clarification or add additional context in comments.

Comments

0

You need to create an $OrderObj to be passed in to the constructor

Comments

0

Just remove public from constructor.

1 Comment

Why "Just remove public from constructor."?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.