INTRODUCTION
PHP is an open-source, interpreted, and object-oriented scripting language that can be executed at the
server-side. PHP is well suited for web development. Therefore, it is used to develop web applications
(an application that executes on the server and generates the dynamic page.).
PHP was created by Rasmus Lerdorf in 1994 but appeared in the market in 1995. PHP 7.4.0 is the latest
version of PHP, which was released on 28 November. Some important points need to be noticed about PHP
are as followed:
- PHP stands for Hypertext Preprocessor.
- PHP is an interpreted language, i.e., there is no need for compilation.
- PHP is faster than other scripting languages, for example, ASP and JSP.
- PHP is a server-side scripting language, which is used to manage the dynamic content of the website.
- PHP can be embedded into HTML.
- PHP is an open-source scripting language.
VARIABLE
In PHP, a variable is declared using a $ sign followed by the variable name. Here, some important
points to know about variables:
- As PHP is a loosely typed language, so we do not need to declare the data types of the variables. It
automatically analyzes the values and makes conversions to its correct datatype.
- After declaring a variable, it can be reused throughout the code.
- Assignment Operator (=) is used to assign the value to a variable.
CONSTANTS
PHP constants are name or identifier that can't be changed during the execution of the script except
for magic constants, which are not really constants. PHP constants can be defined by 2 ways:
- Using define() function
- Using const keyword
Constants are similar to the variable except once they defined, they can never be undefined or
changed. They remain constant across the entire program. PHP constants follow the same PHP variable
rules. For example, it can be started with a letter or underscore only.
Conventionally, PHP constants should be defined in uppercase letters.