The document provides an overview of PHP, including:
- PHP is an open source scripting language widely used for web development. PHP scripts are executed on the server and output HTML.
- PHP files can contain text, HTML, CSS, JavaScript and PHP code. PHP code generates dynamic page content and can interface with databases.
- To use PHP, a web server, PHP and a database like MySQL need to be installed. Core PHP data types include strings, integers, floats, booleans, arrays and objects. Comments start with //, # or /* */.
2. PHP is an acronym for "PHP Hypertext
Preprocessor"
PHP is a widely-used, open source
scripting language
PHP scripts are executed on the server
PHP costs nothing, it is free to download
and use
3. 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"
4. PHP can generate dynamic page content
PHP can create, open, read, write, 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 restrict users to access some
pages on your website
5. PHP can encrypt data
With PHP you are not limited to output
HTML.
We can output images, PDF files, and even
Flash movies.
We can also output any text, such as
XHTML and XML.
6. 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
7. You must:
install a web server
install PHP
install a database, such as MySQL
9. PROGRAM
<?php
echo "<h2>PHP is fun!</h2>”;
echo "Hello world!<br>";
echo "I'm about to learn PHP!<br>";
echo "This", " string", " was", " made",
"with multiple parameters.";
?>
10. OUTPUT
PHP is fun!
Hello world!
I'm about to learn PHP!
This string was made with multiple parameters.
11. A comment in PHP code is a line that is not
read/executed as part of the program.
Its only purpose is to be read by someone
who is editing the code!
PHP supports three ways of commenting:
12. <!DOCTYPE html>
<html>
<body>
<?php
// This is a single line comment
# This is also a single line comment
/* This is a multiple lines comment block that spans
over more than one line */
?>
</body>
</html>
EXAMPLE
16. An integer is a number without decimals.
Rules for integers:
An integer must have at least one digit (0-9)
An integer cannot contain comma or blanks
An integer must not have a decimal point
An integer can be either positive or negative
Integers can be specified in three formats: decimal
(10-based), hexadecimal (16-based - prefixed with
0x) or octal (8-based - prefixed with 0)
17. EXAMPLE
<?php
$x = 5985;
var_dump($x);
echo "<br>";
$x = -345; // negative number var_dump($x);
echo "<br>";
$x = 0x8C; // hexadecimal number var_dump($x);
echo "<br>";
$x = 047; // octal number
var_dump($x);
?>
18. A floating point number is a number with a
Decimal point or a number in exponential form.
In the following example ,the PHP var_dump() function
returns the data type and value of variables:
20. Booleans can be either TRUE or FALSE.
$x=true; $y=false;
Booleans are often used in conditional testing.
21. An array stores multiple values in one single
variable.
<?php
$a=array(“a",“b",“c");
var_dump($a);
?>
22. An object is a data type which stores data and
information on how to process that data.
In PHP, an object must be explicitly declared. First
we must declare a class of object.
For this, we use the class keyword.
A class is a structure that can contain properties
and methods.
24. The special NULL value represents that a variable
has no value. NULL is the only possible value of
data type NULL.
The NULL value identifies whether a variable is
empty or not. Also useful to differentiate between
the empty string and null values of databases.