Learn PHP
PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.
Start learning PHP now »
Easy Learning with "PHP Tryit"
With our online "PHP Tryit" editor, you can edit the PHP code, and click on a button to view the result.
Example
Try it Yourself »
Click on the "Try it Yourself" button to see how it works.
PHP Exercises
PHP Examples
Learn by examples! This tutorial supplements all explanations with clarifying examples.
See All PHP Examples
PHP Quiz Test
Learn by taking a quiz! This quiz will give you a signal of how much you know, or do not know, about PHP.
Start PHP Quiz!
My Learning
Track your progress with the free "My Learning" program here at W3Schools.
Log into your account, and start earning points!
This is an optional feature. You can study W3Schools without using My Learning.
PHP References
W3Schools' PHP reference contains different categories of all PHP functions, keywords and constants, along with examples.
Kickstart your career
Get certified by completing the course
Get certified
w3schoolsCERTIFIED.2022Create a simple HTML form and accept the user name and display the name through PHP echo statement. HTML form: A webform or HTML form on a web page allows a user to enter data that is sent to a server for processing. Forms can resemble
paper or database forms because web users fill out the forms using checkboxes, radio buttons, or text fields. For example, forms can be used to enter railway or credit card data to purchase a product, or can be used to retrieve search results from a search engine. Sample Solution: - PHP Code: Sample Output: PHP : Exercise-4 with Solution
Please input your name:
View the output in the browser
Flowchart:
Have another way to solve this solution? Contribute your code [and comments] through Disqus.
Previous: $var = 'PHP Tutorial'. Put this variable into the title section, h3 tag and as an anchor text within an HTML document.
Next: Write a PHP script to get the client IP address.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
PHP: Tips of the Day
PHP: Send email using the GMail SMTP server from a PHP page.
// Pear Mail Library require_once "Mail.php"; $from = ''; $to = ''; $subject = 'Hi!'; $body = "Hi,\n\nHow are you?"; $headers = array[ 'From' => $from, 'To' => $to, 'Subject' => $subject ]; $smtp = Mail::factory['smtp', array[ 'host' => 'ssl://smtp.gmail.com', 'port' => '465', 'auth' => true, 'username' => '[email protected]', 'password' => 'passwordxxx' ]]; $mail = $smtp->send[$to, $headers, $body]; if [PEAR::isError[$mail]] { echo['' . $mail->getMessage[] . '
']; } else { echo['Message successfully sent!
']; }
Ref : //bit.ly/3aE6MFt
- Exercises: Weekly Top 16 Most Popular Topics
- SQL Exercises, Practice, Solution - JOINS
- SQL Exercises, Practice, Solution - SUBQUERIES
- JavaScript basic - Exercises, Practice, Solution
- Java Array: Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution : Conditional Statement
- HR Database - SORT FILTER: Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution : String
- Python Data Types: Dictionary - Exercises, Practice, Solution
- Python Programming Puzzles - Exercises, Practice, Solution
- C++ Array: Exercises, Practice, Solution
- JavaScript conditional statements and loops - Exercises, Practice, Solution
- C# Sharp Basic Algorithm: Exercises, Practice, Solution
- Python Lambda - Exercises, Practice, Solution
- Python Pandas DataFrame: Exercises, Practice, Solution
- Conversion Tools
- JavaScript: HTML Form Validation