Welcome & Hello World

🐘 PHP Lesson 1 Beginner

PHP (Hypertext Preprocessor) is a widely-used open source server-side scripting language designed specifically for web development. It is the language powering platforms like WordPress, Drupal, and Wikipedia, running behind the scenes of over 70% of modern websites.

1 Server-Side Execution Model

Unlike client-side languages like JavaScript (which execute directly inside the user's browser), PHP code runs **on the web server**. The server processes the PHP code, generates a plain HTML document dynamically, and sends that HTML back to the client's browser. This allows developers to construct dynamic layouts securely.

2 Embedding PHP in HTML & print vs echo

PHP code can be embedded directly inside HTML code using standard PHP wrappers (`<?php ... ?>`). Let's write a simple Hello World script:

PHP — Hello World ▶ Run Code
<?php
echo "Hello, World!\n";
print "Welcome to Our PHP Compiler!\n";
?>

Let's analyze output statements:

  • echo: The primary command used to output text or HTML tags. It is slightly faster than `print` because it does not return a value.
  • print: Similar to `echo`, but returns a value of `1`, allowing it to be used in complex expressions.
3 Code Challenge
Challenge: Edit the code block. Use `echo` to print an HTML header tag (e.g. `<h1>Welcome</h1>`) to verify how HTML tags are rendered from PHP.