Professional Documents
Culture Documents
Integrative Programming and Technologies 7
Integrative Programming and Technologies 7
PHP Introduction
LAPTOP
XAMPP
Basic Syntax of PHP
In PHP, 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 Declaring a variable
In PHP, a variable starts with the $ sign, followed by the name of the variable.
Ex.
$name = “John”;
$number = 5;
$decimal = 10.5;
Unlike other programming languages, PHP has no command for declaring a variable. It is created
the moment you first assign a value to it.
Think of variables as containers for storing data.
Rules for PHP variables
A variable starts with the $ sign, followed by the name of the variable
A variable name must start with a letter or the underscore character
A variable name cannot start with a number
A variable name can only contain alpha-numeric characters and underscores (A-z,
0-9, and _ )
Variable names are case-sensitive ($age and $AGE are two different variables)
Output Variables
With variables
PHP Forms
The PHP superglobals $_GET and $_POST are used to collect form-data.
Both GET and POST are treated as $_GET and $_POST. These are superglobals, which
means that they are always accessible, regardless of scope - and you can access them from
any function, class or file without having to do anything special.
$_GET is an array of variables passed to the current script via the URL parameters.
$_POST is an array of variables passed to the current script via the HTTP POST method.
When to use GET?
Information sent from a form with the GET method is visible to everyone (all
variable names and values are displayed in the URL). GET also has limits on the
amount of information to send. The limitation is about 2000 characters. However,
because the variables are displayed in the URL, it is possible to bookmark the
page. This can be useful in some cases.
GET may be used for sending non-sensitive data.
GET should NEVER be used for sending passwords or other sensitive
information.
When to use POST?
</body>