By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,041 Members | 1,734 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,041 IT Pros & Developers. It's quick & easy.

PHP Class Trouble

P: 48
I am new to OOPS esp in PHP and I am stuck here -

I have a file called dat.php which has a class defined in it. This class has usual functions for database connectivity and error reporting if not connected etc. I use this file anywhere in my application I want to connect to my database.

The constructor is

Expand|Select|Wrap|Line Numbers
  1.     function DB {
  2.        $this->host = 'XXXXXXXX';
  3.        $this->user = 'XXXXXXXX';
  4.        $this->password = 'XXXXXXXXXX';
  5.        $this->database = 'XXXXXXXX';
  6.        $this->persistent = false;
  8.     }
Problem is that I have to encrypt the password (using another encryption function) and retrieve it from another file and I do not want to put username and password here in this file and I do not know how to do that. I definitely cannot remove this class as it has been used at a lot of places.

Can anyone help please?

Jan 9 '08 #1
Share this Question
Share on Google+
1 Reply

P: 48
Well, I came to know that base class constructor does not automatically pass to the derived class. So I put my username and password in a class in some different file. Included this file in the dat.php and in the constructor of the class DB{} I used this =
Expand|Select|Wrap|Line Numbers
  1. class DB extends DB_p {
  3. function DB {
  4. parent::DB_p();
  5. }
  6. }
Any suggestions if this secure?

Jan 9 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.