PHP Tutorial menu

PHP Tutorial

PHP is a programming language that runs on the web server. It builds web pages before they reach the visitor's browser.

A large part of the web runs on PHP, including WordPress, many online shops and lots of company websites. PHP is free, simple to start with, and almost every hosting company supports it.

Why Learn PHP?

  • It is easy for beginners and gives quick results in the browser
  • It works very well with MySQL databases
  • WordPress, Laravel and many freelancing jobs use PHP
  • Cheap shared hosting in Pakistan and abroad supports it out of the box

What You Will Learn

  • How PHP works and how to run it on your own computer
  • Syntax, variables, data types and strings
  • Conditions, loops, functions and arrays
  • Handling HTML forms and sessions safely
  • Classes and objects (object-oriented PHP)
  • Saving and reading data from a MySQL database with PDO

This tutorial uses PHP 8, the modern version of the language.

A First Example

Example

php
<?php
$name = "Ayesha";
echo "Assalam-o-Alaikum, $name! Welcome to PHP.";
Output
Assalam-o-Alaikum, Ayesha! Welcome to PHP.

The server runs this code and sends only the result to the browser. The visitor never sees your PHP code.

Exercises and Quiz

Each lesson ends with a short exercise, and the last lesson is a quiz on the whole tutorial.

Exercise

Where does PHP code run?

What to Learn Next

Before PHP, you should know some HTML and CSS. After PHP, learn SQL to work with databases, and Git to manage your code. If you like Python, compare PHP with Django.

Want to learn with a teacher? The Workownix Full Stack Web Development course takes you from front-end to back-end with real projects, online or at our institute in Orangi Town, Karachi.

Learn PHP with a teacher

Join the Full Stack Development course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp