PHP is the most popular and widely-used server-side scripting language and powers million of websites on the internet. The chances are really high that many of your favorite websites use PHP. PHP is used on the server to create interactive and dynamic websites as opposed to static never-changing pages.
In this Diving into PHP class, learn everything from the syntax for PHP, handling form data, sending emails, using cookies, making database calls, and much more. But first, make sure you meet the prerequisites for this class.
- Intermediate knowledge of HTML. Luckily for you, we have a great class on that
- An environment to run PHP. This can be Internet Information Services (IIS), Apache, or your own web server
With that being said, let's dive into PHP!
Since PHP is ultimately just plain text, you can use any text editor you want for this class. With that being said, we suggest using the Atom text editor. It will support the operating system you're running on, and its syntax highlighting makes writing PHP fun!
Of course, feel free to use whatever text editor you might already be using.
The easiest way to get started with PHP is to just do a
Hello World example. Create a new file called
.php file extension lets the server know that this is a PHP file and that it should run any code that happens to be in the file. Inside the file, and enter this:
<!DOCTYPE html> <html> <head> <title>Diving into PHP</title> </head> <body> <?php // Display the text 'Hello World' echo 'Hello World'; ?> </body> </html>
Save the file and access it in your browser. As you might expect, you get an otherwise blank page with the text
Hello World in it. If you were able to see:
You have everything you need to continue on with this class on PHP!