PHP Training → Lesson 01
What PHP is, how it works with a web server, and how to write and run your very first script.
echo to output textphpinfo() to inspect your environmentHere's the code written in the video. You can copy and paste these directly into a .php file on your server.
<?php
// Your first PHP script
echo "Hello, world!";
// You can also use print
print "<p>This is a paragraph.</p>";
?>
<?php
// This outputs a full page of info about your PHP installation.
// Delete this file from your server once you're done with it!
phpinfo();
?>
<!DOCTYPE html>
<html>
<head>
<title>My First PHP Page</title>
</head>
<body>
<h1>Welcome</h1>
<?php
$name = "World";
echo "<p>Hello, " . $name . "!</p>";
?>
</body>
</html>
PHP files need a server. Unlike HTML, PHP won't run if you just open the file in a browser. You need a web server (Apache, Nginx) or a local environment like XAMPP or Laragon.
Delete phpinfo.php when you're done. It exposes details about your server configuration that you don't want public.