Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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.
$wpdb
you can get anywhere your db name using
<?php echo DB_NAME; ?> <?php echo DB_USER; ?>
or
To get the db name using $wpdb:
global $wpdb; echo $wpdb->dbname;
It will return database name as a string.
Add a comment
You can get database name by DB_NAME constant.You can check by printing it
<?php echo DB_NAME; ?>
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.