BY ANCY RAJU
Venture software technologies
 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
 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"
 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
 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.
 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
You must:
 install a web server
 install PHP
 install a database, such as MySQL
<?php
PHP code goes here
?>
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.";
?>
OUTPUT
PHP is fun!
Hello world!
I'm about to learn PHP!
This string was made with multiple parameters.
 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:
<!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
 String
 Integer
 Floating point numbers
 Boolean
 Array
 Object
 NULL
 A string is a sequence of characters, like "Hello
world!".
 A string can be any text inside quotes.
 We can use single or double quotes:
EXAMPLE
<?php $x = "Hello world!";
echo $x;
echo "<br>";
?>
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)
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);
?>
 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:
EXAMPLE
<?php
$x = 10.56765;
var_dump($x);
echo "<br>";
$x = 2.4e3;
var_dump($x);
echo "<br>";
$x = 8E-5;
var_dump($x);
?>
 Booleans can be either TRUE or FALSE.
 $x=true; $y=false;
 Booleans are often used in conditional testing.
 An array stores multiple values in one single
variable.
<?php
$a=array(“a",“b",“c");
var_dump($a);
?>
 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.
EXAMPLE
<?php
class Car
{
var $color;
function Car($color="green")
{
$this->color = $color;
}
function what_color()
{
return $this->color;
}
}
?>
 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.
EXAMPLE
<?php
$x="Hello world!";
$x=null;
var_dump($x);
?>
Thank u

Php

  • 1.
    BY ANCY RAJU Venturesoftware technologies
  • 2.
     PHP isan 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 filescan 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 cangenerate 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 canencrypt 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 runson 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:  installa web server  install PHP  install a database, such as MySQL
  • 8.
  • 9.
    PROGRAM <?php echo "<h2>PHP isfun!</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! Helloworld! I'm about to learn PHP! This string was made with multiple parameters.
  • 11.
     A commentin 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 // Thisis 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
  • 13.
     String  Integer Floating point numbers  Boolean  Array  Object  NULL
  • 14.
     A stringis a sequence of characters, like "Hello world!".  A string can be any text inside quotes.  We can use single or double quotes:
  • 15.
    EXAMPLE <?php $x ="Hello world!"; echo $x; echo "<br>"; ?>
  • 16.
    An integer isa 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 floatingpoint 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:
  • 19.
    EXAMPLE <?php $x = 10.56765; var_dump($x); echo"<br>"; $x = 2.4e3; var_dump($x); echo "<br>"; $x = 8E-5; var_dump($x); ?>
  • 20.
     Booleans canbe either TRUE or FALSE.  $x=true; $y=false;  Booleans are often used in conditional testing.
  • 21.
     An arraystores multiple values in one single variable. <?php $a=array(“a",“b",“c"); var_dump($a); ?>
  • 22.
     An objectis 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.
  • 23.
    EXAMPLE <?php class Car { var $color; functionCar($color="green") { $this->color = $color; } function what_color() { return $this->color; } } ?>
  • 24.
     The specialNULL 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.
  • 25.
  • 26.