Bird
0
0

What will the following code output if the wp_users table has 5 users?

medium📝 Predict Output Q4 of 15
Wordpress - WordPress Query and Database
What will the following code output if the wp_users table has 5 users?
$count = $wpdb->get_var('SELECT COUNT(*) FROM wp_users');
echo $count;
A5
BAn array of 5 objects
CNULL
DError: Invalid query
Step-by-Step Solution
Solution:
  1. Step 1: Understand get_var() usage

    This method returns a single value from the first column of the first row.
  2. Step 2: Analyze the query

    The query counts users, so it returns 5 as a number.
  3. Final Answer:

    5 -> Option A
  4. Quick Check:

    get_var() returns single value [OK]
Quick Trick: Use get_var() to get single value like counts [OK]
Common Mistakes:
  • Expecting array output
  • Confusing get_var() with get_results()
  • Thinking query fails

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes