2. What is PHP?
is an acronym for “PHP: Preprocessor”
a widely-used, open source scripting language
a powerful tool for making dynamic and interactiveWeb pages.
3. What is PHP
File?
can contain text, HTML,CSS, JavaScript, and PHP code
PHP code are executed on the server, and the result is returned to
the browser as plain HTML
PHP files have extension ".php"
4. What can PHP
Do?
PHP can generate dynamic page content
PHP can create, open, read, write, delete, and close files on the
server
PHP can collect form data
PHP can send and receive cookies
PHP can add, delete, modify data in your database
PHP can be used to control user-access
PHP can encrypt data
With PHP you are not limited to output HTML.You can output
images, PDF files, and even Flash movies.You can also output
any text, such as XHTML and XML.
5. Why PHP?
PHP runs on various platforms (Windows, Linux, Unix, Mac OS X,
etc.)
PHP is compatible with almost all servers used today (Apache, IIS,
etc.)
PHP supports a wide range of databases
PHP is free. Download it from the official PHP resource:
www.php.net
PHP is easy to learn and runs efficiently on the server side
6. What do we
need to run
PHPScript?
Linux or Windows - provides the base operating system (OS) and
server environment
Apache or IIS (HTTP SERVER) – intercepts HTTP request and
either serves them directly or passes them on the PHP Interreter
for execution.
MySQL - the MySQL RDBMS serves as the data storage engine,
accepting connections from the PHP layer and inserting,
modifying, or retrieving data
PHP PACKAGE - the PHP interpreter parses and executes PHP
code, and returns the results to the web server
7. Four Rules in
PHP coding
PHP script starts with <?php and ends with ?>
PHP statement must end in a semicolon (;)
Text that is not a command must be put in quotes
Any time you have a curly bracket or parenthesis, you should have
a matching end bracket or parenthesis.
9. Remember:
You can insert the PHP scripts in any portions of the HTML tags.
Also you can embed HTML tags in PHP statements however it will be
treated as text.
' ' (Single Quotes)
Content inside single quotes is evaluated literally.
Example
$string = 'Single Quotes';
echo '$string'; //Outputs: $string
"" (double quotes) –Variables inside double quotes are evaluated for
their values.
Example
$string= "Single Quotes ";
echo " $string "; //Outputs: Single Quotes
10. Variables and
DataTypes
Rules in
Naming PHP
Variables
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)
11.
12. DataTypes
The values assigned to a PHP variable may be of different data types
including simple string and numeric types to more complex data types
like arrays and objects.
PHP supports eight data types:
1. String
2. Integer
3. Float (floating point numbers - also called double)
4. Boolean
5. Array
6. Object
7. NULL
13. PHPStrings
A string is a sequence of characters, like "Hello world!".
A string can be any text inside quotes.You can use single or double
quotes:
18. DataTypes
The values assigned to a PHP variable may be of different data types
including simple string and numeric types to more complex data types
like arrays and objects.
PHP supports eight data types:
1. String
2. Integer
3. Float (floating point numbers - also called double)
4. Boolean
5. Array
6. Object
7. NULL
21. DataTypes
The values assigned to a PHP variable may be of different data types
including simple string and numeric types to more complex data types
like arrays and objects.
PHP supports eight data types:
1. String
2. Integer
3. Float (floating point numbers - also called double)
4. Boolean
5. Array
6. Object
7. NULL
23. DataTypes
The values assigned to a PHP variable may be of different data types
including simple string and numeric types to more complex data types
like arrays and objects.
PHP supports eight data types:
1. String
2. Integer
3. Float
4. Boolean
5. Array
6. Object
7. NULL
25. DataTypes
The values assigned to a PHP variable may be of different data types
including simple string and numeric types to more complex data types
like arrays and objects.
PHP supports eight data types:
1. String
2. Integer
3. Float
4. Boolean
5. Array
6. Object
7. NULL
28. PHPOperators
Operators are used to perform operations on variables and values.
PHP divides the operators in the following groups:
1. Arithmetic
2. Relational
3. Logical
4. String
5. Unary
32. PHPOperators
Operators are used to perform operations on variables and values.
PHP divides the operators in the following groups:
1. Arithmetic
2. Relational
3. Logical
4. String
5. Unary
36. PHPOperators
Operators are used to perform operations on variables and values.
PHP divides the operators in the following groups:
1. Arithmetic
2. Relational
3. Logical
4. String
5. Unary
41. Conditional
Control
Structure
if statement - executes some code only if a specified condition is
true
if...else statement - executes some code if a condition is true and
another code if the condition is false
if...elseif....else statement - specifies a new condition to test, if
the first condition is false switch statement - selects one of
many blocks of code to be executed