PHP Get Started
Getting started is the path from a written PHP file to printed output. The steps stay the same for every program in this course.
The full shape
The full shape has the opening tag and one statement. The statement prints one line.
<?php
echo "Let's get started.\n";Two statements in order
Two statements run from top to bottom. Each statement prints one line.
<?php
echo "Step one\n";
echo "Step two\n";Example
<?php
echo "Program started.\n";
echo "Program finished.\n";Key points
- The PHP file in this course is named main.php.
- Use php main.php to run the file.
- A statement is one complete instruction in a program.
- Each statement ends with a semicolon.
- Pure PHP files leave out the closing ?> tag on purpose.
In this example, two statements run in order. The first statement prints Program started. The second statement prints Program finished.
Try it Yourself
Edit the code, then press Run.
Running is simulated ยท Programiz PHP Compiler
Exercise
Which command runs the file main.php?