Why string functions matter
📖 Scenario: You are building a simple PHP program to handle user input for a website. Users enter their names, but sometimes they add extra spaces or use different letter cases. To make the names look neat and consistent, you need to use string functions.
🎯 Goal: Create a PHP script that cleans up a user's name by removing extra spaces and making the first letter uppercase and the rest lowercase.
📋 What You'll Learn
Create a variable called
userName with the exact value " aLExAnDeR ".Create a variable called
cleanName that trims spaces from userName.Use string functions to make the first letter uppercase and the rest lowercase in
cleanName.Print the final cleaned name using
echo.💡 Why This Matters
🌍 Real World
Cleaning and formatting user input is common in websites and apps to keep data consistent and readable.
💼 Career
Knowing string functions helps you prepare data for display, storage, or further processing in many programming jobs.
Progress0 / 4 steps