Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to get WordPress database name. I have also try to get database name from $wpdb but failed. When print the $wpdb it give an object array but i don't know how to get database name from object array.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

To get the db name using $wpdb:

global $wpdb;
echo $wpdb->dbname;

It will return database name as a string.

share|improve this answer
    
Thanks @The Sufi –  user3698265 Jun 2 at 6:38

You can also get the database name from the constant DB_NAME without going for $wpdb.

share|improve this answer
    
This is best answer. –  ahmetlutfu Jun 2 at 9:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.