PHP 1
PHP 1
Introduction
• PHP is a server scripting language, and a powerful
tool for making dynamic and interactive Web pages.
• PHP is a widely-used, free, and efficient alternative
to competitors such as Microsoft's ASP.
What is a PHP File?
• PHP files 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"
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 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.
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, Mercury, FileZilla, Tomcat 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
gfgf
PHP Data Types
PHP 5 Syntax
• A PHP script is executed on the server, and the plain
HTML result is sent back to the browser.
• A PHP script can be placed anywhere in the
document.
• A PHP script starts with <?php and ends with ?>:
• A PHP file normally contains HTML tags, and some
PHP scripting code.
• PHP statements end with a semicolon (;).
PHP Case Sensitivity
• In PHP, all keywords (e.g. if, else, while, echo, etc.),
classes, functions, and user-defined functions are
NOT case-sensitive.
• All variable names are case-sensitive.
PHP Variables
• A variable can have a short name (like x and y) or
a more descriptive name (age, carname,
total_volume).
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)
PHP is a Loosely Typed Language