Bird
0
0

How can you convert a string to uppercase but keep the first letter lowercase in PHP?

hard📝 Application Q9 of 15
PHP - String Functions
How can you convert a string to uppercase but keep the first letter lowercase in PHP?
A$result = lcfirst(strtoupper($input));
B$result = ucfirst(strtolower($input));
C$result = strtolower(ucfirst($input));
D$result = strtoupper(lcfirst($input));
Step-by-Step Solution
Solution:
  1. Step 1: Understand the requirement

    Convert all letters to uppercase except the first letter which should be lowercase.
  2. Step 2: Analyze function combination

    strtoupper($input) makes all uppercase, then lcfirst() converts first letter to lowercase, achieving the goal.
  3. Final Answer:

    $result = lcfirst(strtoupper($input)); -> Option A
  4. Quick Check:

    Uppercase with first letter lowercase = $result = lcfirst(strtoupper($input)); [OK]
Quick Trick: Use strtoupper() then lcfirst() to lowercase first letter [OK]
Common Mistakes:
  • Using ucfirst() instead of lcfirst()
  • Applying strtolower() incorrectly
  • Reversing function order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes