PHP class referencing confusion across multiple files

Posted by DssTrainer on Stack Overflow See other posts from Stack Overflow or by DssTrainer
Published on 2010-12-22T20:49:24Z Indexed on 2010/12/22 20:54 UTC
Read the original article Hit count: 176

Filed under:
|
|
|

I have an index.php file that has 3 includes

<?php
require_once('mod.php');
$mod = new Mod();

require_once('start.php');
require_once('tools.php');

....some code....
?>

I need to be able to reference the $mod object inside the start.php and tools.php. How do I pass that object to be referenced by those 2 other require files?

Basically the mod.php is a class that has an array list generated in its __construct(). I want to use that array list data inside the startup.php and tools.php file but not sure how to pass in the existing one without calling "new" inside both of those files separately which doesn't do what I need since it resets everything.

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about reference