PHP classes and file includes

db , php United Kingdom
  • 13 years ago

     Hi guys and girls,

     I've ran into a problem with PHP, I'm a C++ programmer by trade but a certain contract requires I use PHP.  However my problem is as follows:

     I'm trying to seperate all the PHP logic from inline (I know class constructs etc will still need to be inline) to make it more manageable - however I'm wanting to store global parameters in a file i.e. database server, username, password etc etc and include this in a MyClass.class.php file so the constructor of the class can access these - but it doesn't seem possible.  I've heard that this isn't a feature in PHP?!?!?!?!

    My directory structure looks something like:

    • ROOT
      • classes
        • MyClass.class.php (the class wanting to use the
      • config
        • (contains the global config files for this site)
      • admin.php

     And so in the MyClass.class.php I have

    but it doesn't seem to work...

    Is there some other way around this? Before you answer please bear in mind that the server is many miles away and I have NO access to the php.ini file.

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Some people, when confronted with a problem, think "I know, I’ll use regular expressions." Now they have two problems.” - Jamie Zawinski