I've noticed that we don't have many PHP tutorials. Here's a basic one on how to print "Hello world!" to the users' screens.
There are many different ways to output data. The most common is to use the echo function, demonstrated below.
Let's break down this code.
This is the tag that all PHP scripts need in order to "activate" PHP.
This line makes use of the echo function. It's pretty self-explanatory. This function outputs what ever is in the quotes. You can also use two apostrophes instead of quotes, but try to be consistent. And never forget that most of time, your lines should end with a semicolon!
Simply signifies the end of a PHP script.
The next data output function we're going to use is print(). The print function is demonstrated below.
Same concept applies to this script. You have your opening tags, then the function, with whatever text INSIDE the quotes, your semicolon, and your ending tags.
Hope you enjoyed! More PHP tutorials to come!
There are many different ways to output data. The most common is to use the echo function, demonstrated below.
PHP:
<?php
echo "Hello world!";
?>
Let's break down this code.
PHP:
<?php
This is the tag that all PHP scripts need in order to "activate" PHP.
PHP:
echo "Hello world!";
This line makes use of the echo function. It's pretty self-explanatory. This function outputs what ever is in the quotes. You can also use two apostrophes instead of quotes, but try to be consistent. And never forget that most of time, your lines should end with a semicolon!
PHP:
?>
Simply signifies the end of a PHP script.
The next data output function we're going to use is print(). The print function is demonstrated below.
PHP:
<?php
print("Hello world!");
?>
Same concept applies to this script. You have your opening tags, then the function, with whatever text INSIDE the quotes, your semicolon, and your ending tags.
Hope you enjoyed! More PHP tutorials to come!