Ad space (banner)
๐Ÿ˜PHP Lessons
Lesson 2 / 68

Your First Output (echo)

In this lesson you will learn the basic way to print output in PHP with echo, and get a feel for a language that runs on a web server. This is for anyone searching for "PHP echo how to use" or "PHP basic syntax".

PHP prints text to the screen with echo. Code always starts with the <?php tag. What sets PHP apart is that it runs on a web server and can be embedded directly in HTML. Since its arrival in 1994 it has powered a huge share of the world's websites, making it a defining language of web development.

The sample code writes a single line, echo "Hello, PHP!";, inside a <?php tag. Famous content management systems such as WordPress are built in PHP, so learning the basics that start with echo is a first step towards understanding those large systems too.

A common stumbling block for beginners is forgetting the opening <?php tag. Without it, the code is not recognised as PHP and gets printed to the screen as plain text. Missing the semicolon ; at the end of a line is another frequent slip.

In practice PHP runs on the server and sends the result to the browser as HTML, so the source is never visible to the client. That "runs server-side" property is one reason PHP has stayed in use in web development for so long.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run PHP directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)