This document provides an overview of PHP including:
1. A brief history of PHP including its origins and versions. PHP was created in 1994 and has evolved through versions like PHP/FI, PHP3, PHP5, and PHP7.
2. Descriptions of core PHP features like being open source, developing dynamic web applications, and supporting various databases.
3. Explanations of PHP syntax including tags, variables, naming conventions, constants, data types, and operators like arithmetic, assignment, comparison, increment/decrement, logical, and string operators.
4. Sections on specific PHP concepts like variables, constants, data types, expressions, and different types of operators. Variables are declared with
3. History of PHP:
• PHP is an "HTML-embedded scripting language" primarily used for
dynamic Web applications.
• PHP takes most of its syntax from C, Java, and Perl.
• It is an open source technology and runs on most operating systems and
with most Web servers.
• PHP was written in the C programming language by Rasmus Lerdorf in
1994 for use in monitoring his online resume and related personal
information.
• For this reason, PHP originally stood for "Personal Home Page"
4. Versions of PHP
• PHP2:
• The code got another complete makeover, and in April of 1996, combining the
names of past releases, Rasmus introduced PHP/FI(form interface). This second-
version of PHP implementation began to truly evolve PHP from a suite of tools
into a programming language in its own right.
• PHP3:
• PHP 3.0 was the first version that closely resembles PHP as it exists today.
Finding PHP/FI 2.0 still inefficient and lacking features they needed to power an
eCommerce application developers,began yet another complete rewrite of the
underlying parser in 1997. In an effort to improve the language developes
decided to collaborate in the development of a new, independent programming
language. This entirely new language was released under a new name, that
removed the implication of limitedpersonal use that the PHP/FI 2.0 name held.
It was renamed simply 'PHP', with the meaning becoming a recursive acronym -
PHP: Hypertext Preprocessor.
5. Versions of PHP
• PHP5:
• PHP 5 was released in July 2004 after long development and several pre-
releases. It is mainly driven by its core, the Zend Engine 2.0 with a new
object model and dozens of other new features.PHP's development team
includes dozens of developers, as well as dozens others working on PHP-
related and supporting projects, such as PEAR, PECL, and documentation,
and an underlying network infrastructure of well over one-hundred
individual web servers on six of the seven continents of the world.
• PHP7:
• The PHP development team released the latest version of PHP: PHP 7
claiming it to be twice as fast as its predecessor PHP 5. So, is migrating to
PHP 7
6. Features and Advantages Of PHP:
• Features Of PHP:
• 1. Open Source
• 2. Develops Dynamic Web sites
• 3. Needs Web server to run
• 4. Supports various datrabases.
• Advantages of PHP:
• 1. Free of Cost
• 2. Open Source
• 3. Platform Independent
• 4. Easy to learn
7. Syntax of PHP:
• Canonical PHP Tags:The script starts with <?php and ends with ?> . These
tags are
• also called ‘Canonical PHP tags’. Every PHP command ends with a semi-
colon (;).
• Let’s look at the hello world program in PHP:
• <?php
• // Here echo command is used to print
• echo "Hello, world!";
• ?>
8. 1.1 Variables in PHP:
• Variables are used to store data, like string of text, numbers, etc. Variable
values can change over the code. Here're some important things to know
about variables:
• In php variable is declared by following $ symbol.
• In PHP, a variable does not need to be declared before adding a value to
it. PHP automatically converts the variable to the correct data type,
depending on its value. i.e $roll=34; roll variable will get auto declaration
to integer.
• After declaring a variable it can be reused throughout the code.
• The assignment operator (=) used to assign value to a variable.
9. 1.1 Variables in PHP:
• <?php
• $name="nilesh"; //String Variable Declared
• $roll=7; //Int Variable Declared
• $per=NULL; //Blank Variable Declared for later use
• var_dump($name); //display output with data type and value
• var_dump($roll); //display output with data type and value
• var_dump($per); //display output with data type and value
• $per=65.35; //assigning value
• var_dump($per); //display output with data type and value
• echo $name //display value
• print $name //display value
• ?>
10. 1.2 Naming Conventions for PHP Variables
• These are the following rules for naming a PHP variable:
• All variables in PHP start with a $ 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 in PHP can only contain alpha-numeric characters and
underscores (A-z, 0-9,and _).
• A variable name cannot contain spaces.
• The variable name is case sensitive.
11. 2. Constant in PHP
• A constant is a name or an identifier for a fixed value. Constant are like
variables, except that once they are defined, they cannot be changed.
Constants are very useful for storing data that doesn't change while the
script is running.
• Common examples of such data include configuration settings such as
database username and password, website's base URL, company name,
etc.
• Constants are defined using PHP's define() function, which accepts two
arguments: the name of the constant, and its value
• Syntax: define(“variable_name”,value)
• Example: 1) define(“pi”,3.14); 2) define(“dept”,”CSE”);
13. 4. PHP Operators & Expressions
• 4.1 Expressions:
• Expression is nothing but the combination of multiple variables along
with Operator.
• Example: &a+$b+$c; here a b c are variables and + is operator
• $a>$b here a b are variables and > is operator.
14. 4.2 Operators
• Operators are symbols that tell the PHP processor to perform certain
actions.
• For example, the addition (+) symbol is an operator that tells PHP to add
two variables or values,
• while the greater-than (>) symbol is an operator that tells PHP to
compare two values.