• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
classNames and __construct

[eluser]Richard Testani[/eluser]
I'm trying to figure out what the differences are in the 2 versions.
In the following, I've set:
$route['default_controller'] = "index";

I know in php4 you use the class name as the construct and in php5 you'd use __construct().
I'm running php5, so it's __construct() for me, yet...
class Index extends Controller {

public function __construct() {

  $bsn_data['mode'] = 'test';

Returns file not found. status 404.
I'm not sure why.
Once I add the following to the Index class it works:
public function Index() {

I can't figure out the why's on this one.

Will naming a controller index not cause a problem as it's the default function... which in this case would also be the constructor?

[eluser]Richard Testani[/eluser]
Good question, I hadn't thought about it that way - is Index a reserved name?.
I'll test it out with a different name.


It appears so, reserved names

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.