0% found this document useful (0 votes)
19 views21 pages

PHP

PHP is a server-side scripting language primarily used for creating dynamic web pages, originally standing for Personal Home Page. It features a syntax similar to C, is free to use, and compatible with various platforms and databases. PHP allows for file handling, form processing, and user access control, and supports multiple data types including strings, integers, floats, and arrays.

Uploaded by

darpanstha5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views21 pages

PHP

PHP is a server-side scripting language primarily used for creating dynamic web pages, originally standing for Personal Home Page. It features a syntax similar to C, is free to use, and compatible with various platforms and databases. PHP allows for file handling, form processing, and user access control, and supports multiple data types including strings, integers, floats, and arrays.

Uploaded by

darpanstha5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

PHP

INTRODUCTION OF PHP
• PHP is the server side scripting programming language used
to solve the web related problem.
• Generally, it is used to create the dynamic web pages.
• PHP originally stood for Personal Home Page or Hypertext
Preprocessor.
• When a person request for any PHP page in the address bar
of the browser that request is first sent to the server then
server interpret PHP files and return back response in form
of HTML. That’s why it is called Hypertext preprocessor.
• Rasmus Lerdorf released the first version of PHP way back
in 1994.
FEATURES OF PHP
• This syntax of PHP is similar to C, so it is easy to learn
and use.
• PHP runs efficiently on the server side.
• PHP is the free software in the PHP license. We can
easily download it from the official PHP website.
• PHP runs on various platform like windows, Linux,
Unix, Max OS etc.
• It is compatible with almost all server used today like
Apache, IIS etc.
• It supports wide range of database.
Common uses of PHP
• By using PHP, we can create, open, read, write and
close files.
• It can handles forms i.e. gather data from files, save
data to a file, through email we can send data,
return data to the user.
• We can add, delete and modify elements or data
within database through PHP.
• We can also restrict users to access some pages of
our websites.
• It can encrypt data.
PHP FILES
• PHP files contain text, HTML, CSS, JavaScript
and PHP code.
• PHP code is executed on the server, and the
result is returned to the browser as plain
HTML.
• PHP files have extension .PHP.
Hardware and software requirement
Hardware requirement Software requirement
1) 1GHZ CPU Processor 1) Operating System:
Windows, Unix, Linux
2) 2GB RAM
2) Web server: Apache Web
3) 1 GB HARD DISK Server, IIS server (Internet
Information Server).
3) PHP version: PHP 5.4 and
above.
4) Database: MySql 5.1 and
above, Micro soft SQL
server 2000 or above.
Basic PHP Syntax
• A PHP script can be placed anywhere in the
document.
• A PHP script starts with <? Php and ends
with ?>
<?php // PHP code goes here?>
The default file extension for PHP files is .PHP.
A PHP file normally contains HTML tags, and
some PHP scripting code.
<html>
<head>
<title>…………..
</title>
</head>
<body>
<h1> My first PHP page</h1>
<?php echo ”Hello”?> //PHP code
</body>
</html>
PHP DATA TYPES
1. String:
 A string is a sequence of characters.
 It contains number, letter or symbol.
 A string can be any text inside quotes.
 We can use single or double quotes.
 String is followed by a symbol.
Examples:
$x=“My college”;
$y=‘My college’;
2. PHP interger
 An integer data type is a non decimal number.
 It may be positive or negative number.
 Integer may be 1009, 45254, 952, -54625 etc.
 $ is used for any variable like integer, float,
string, otherwise syntax error will be occurred.
Example:
$x=1234;
3. PHP float:
 A float is a number with a decimal point or a
number in exponential form.
 It may be positive or negative.
 The float data type can commonly store a
value up to maximum precision of 14 digits.
i.e. 1.12345678912345.
Example:
$x=14.1414;
4. PHP Boolean
 A Boolean represents two possible states:
TRUE or FALSE.
 Generally, it is used for conditional testing.
Example:
$x=true;
$y=false;
5. PHP Array:
 An array stores multiple values in one single
variable.
 “array” is a keyword used for PHP array.
Example:
$cars=array(“Hundia”, ”BMW”, ”Toyata”);
Here $cars is an array which stores three values.
6. PHP Object:
 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 declare the class of object. For this, we use the class and $this keyword.
 A class is a structure that can contain properties and methods.
Example:
<?php
Class Car
{
function Car()
$this->model=“VW”;
}
// create an object
$bie=new Car();

// show object properties


Echo $->model
?>
7. PHP NULL Value
 A variable of data type.
 Null is a variable that has no value assigned to it.
 Null is a special data type which can have only one
value: NULL
Example:
<?php
$x=“hello world”;
$x=null;
Var_dump($x);
?>
PHP Variables:
 Variables are used to store information.
 Information may be string, numeric or symbols.
Rules for PHP variables:
 A variables starts with the $ sign, followed by the name of
variable.
 A variable name must start with a letter of the underscore
character.
 A variable name cannot start with a number.
 A variable name can only contain alpha-numeric characters
and underscores
 Variable names are case sensitive.
Declaration of PHP variables:
<html>
.
.
<body>
<?php
$txt=“hello world”;
$x=5;
$y=1.5;
// for displaying the output

echo $txt;
echo”<br>”;
echo $x;
echo”<br>”;
echo $y;
?>
</body>
ECHO AND PRINT
Echo
• Echo is a statement i.e used to display the output. it can be
used with parentheses echo or without parentheses echo.
• Echo can pass multiple string separated as ( , )
• Echo doesn't return any value
• Echo is faster then print
Example 1
<?php
$name="John";
echo $name;
//or echo ($name);
?>
Example 2 (pass multiple argument)
<?php
$name = "John";
$profile = "PHP Developer";
$age = 25;
echo $name , $profile , $age, " years old";
?>
Print
 Print is also a statement i.e used to display the output. it
can be used with parentheses print( ) or without
parentheses print.
 using print doesn't pass multiple argument
 print always return 1
 it is slower than echo
Example
<?php
$name="John";
print $name;
//or print ($name);
?>
PHP OPERATORS
 Operators are used to perform operations on
variables and values.
 PHP divides the operators in the following
groups:
1. Arithmetic Operators
2. Comparison Operators
3. Logical (or Relational) Operators
4. Assignment Operators
5. Conditional (or ternary) Operators

You might also like