<?php ?>

What is PHP?

Theoretically speaking, it's a server-side scripting language

Those are a lot of fancy words, but what is it exactly?

Client 

Server

Request + Data

Browser

 

Response

Remote machine

So how does it work?

PHP code is written in conjunction with the HTML files. The extension gets changed to '.php' to inform the server that this file is to be processed.

In a way, the PHP code will tell the server what to do with the request from the user, and also the data he has sent. The PHP will be executed only when a client requests the file.

Basic Syntax

How is it identified by the server?

<?php 
// code goes here
?>

PHP is  enclosed like this. There can be multiple such enclosures in a single file, and all of them will be executed sequentially, when requested.

PHP statements end with a semicolon ;

Case Sensitivity

In PHP, all keywords (e.g. if, else, while, echo, etc.), classes, functions, and user-defined functions are NOT case-sensitive. However; all variable names are case-sensitive.

<?php
ECHO "Hello World!<br>";
echo "Hello World!<br>";
?>

<?php
$color = "red";
echo "My car is " . $color . "<br>";
echo "My house is " . $COLOR . "<br>";
?>

echo

echo is a function which outputs data to 

deck

By Srajan Garg

deck

  • 1,298