1. Introduction to PHP
History of PHP: PHP (Hypertext Preprocessor) was originally created by Rasmus Lerdorf in 1994 as
a simple scripting language for web development.
Characteristics of PHP: PHP is a server-side scripting language designed primarily for web
development but also used as a general-purpose language. It is embedded in HTML to generate
dynamic web pages.
Structure of a PHP Program: PHP code is embedded within HTML using <?php and ?> tags, and
the script is executed on the server side.
2. Data Types and Variables in PHP
Basic Data Types: PHP supports data types like int (integer), float (floating-point), string (sequence
of characters), array (indexed collection), and boolean.
Variables: Variables in PHP are dynamically typed and start with the $ symbol. They are
case-sensitive and can store different types of data.
Constants and Literals: PHP constants are defined using the define() function, and literals represent
fixed values used directly in the code.
3. Operators in PHP
Arithmetic Operators: Includes +, -, *, /, % for performing basic arithmetic.
Relational Operators: Used to compare values, such as ==, !=, >, <.
Logical Operators: Logical operations include && (AND), || (OR), ! (NOT).
Assignment Operators: Assignment uses = to assign values, and other operators include +=, -=, *=,
etc.
4. Control Structures in PHP
if, if-else, and elseif statements: Used for conditional execution of code blocks.
switch-case statement: Provides a way to select one of many blocks of code based on the value of a
variable.