PHP Introduction

What PHP is and how it works.

✍️ 2 exercises in this lesson

PHP (PHP: Hypertext Preprocessor) is a server-side scripting language. PHP code runs on the server, and the browser only receives the resulting HTML.

What PHP can do

  • Generate dynamic page content.
  • Read and save data in databases such as MySQL.
  • Handle forms, logins, sessions and cookies.
  • Create, read and upload files.
  • Power frameworks and CMSs like Laravel, Symfony and WordPress.

PHP files end in .php and can mix HTML with PHP code.

Key Takeaways: PHP Introduction

Mastering PHP Introduction helps you write clean and reliable PHP code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

PHP Introduction Code Example

PHP
<!DOCTYPE html>
<html>
<body>
  <h1><?php echo "Hello from PHP!"; ?></h1>
  <p>Today is <?php echo date("l"); ?>.</p>
</body>
</html>
Output
Hello from PHP!
Today is Thursday.
Run this example on your own computer. The "Get Started" lesson shows how to set it up.

PHP Introduction Practice Exercises

Check what you learned in “PHP Introduction”.

/ 2 solved
Fill in the blank

Open a block of PHP code.

 echo "Hello"; ?>
✓ Correct! Not quite. Try again.
Multiple choice

Where does PHP code run?

✓ Correct! Not quite. Try again.
to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services