I've come across one issue which I'm not clear on;
The two examples below should in my eyes have the same output but they dont, the last example errors with it unable to find the class for some reason.
EXAMPLE 1
index.php
Outputs;PHP Code:<?php
$test = new Testing;
class Controller
{
public function Controller()
{
echo "Auto Load Controller Method<br>";
}
public function Display_Msg_From_Controller()
{
echo "Displaying Message from Controller Method<br>";
}
}
class Testing extends Controller
{
function Testing()
{
parent::Controller();
$this->Display_Msg_From_Controller();
}
}
?>
Quote:
Auto Load Controller Method
Displaying Message from Controller Method
EXAMPLE 2 : Controller class has been placed in an external file and included instead.
index.php
external file controller.phpPHP Code:<?php
include "controller.php"; //Contains Controller class (see below)
$test = new Testing;
class Testing extends Controller
{
function Testing()
{
parent::Controller();
$this->Display_Msg_From_Controller();
}
}
?>
Outputs;PHP Code:<?php
class Controller
{
public function Controller()
{
echo "Auto Load Controller Method<br>";
}
public function Display_Msg_From_Controller()
{
echo "Displaying Message from Controller Method<br>";
}
}
?>
Why should it fail to find the class Testing when all I did was make Controller an include??? :s :oQuote:
Fatal error: Class 'Testing' not found in C:\xampp\htdocs\testx\index.php on line 4
Kind regards
Dal

