0% found this document useful (0 votes)
214 views25 pages

Quick Tour: Abhinav Nath Gupta IT Final Yr (0700113002

This document provides an overview of PHP. It discusses that PHP is a general purpose scripting language used for server-side web development. It notes that PHP is easy to use and learn, supports object-oriented programming, and is open source. The document then covers how to write basic PHP code, use variables and data types, control structures like loops, work with strings and arrays, and embed PHP within HTML.

Uploaded by

Blade Snipes
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
214 views25 pages

Quick Tour: Abhinav Nath Gupta IT Final Yr (0700113002

This document provides an overview of PHP. It discusses that PHP is a general purpose scripting language used for server-side web development. It notes that PHP is easy to use and learn, supports object-oriented programming, and is open source. The document then covers how to write basic PHP code, use variables and data types, control structures like loops, work with strings and arrays, and embed PHP within HTML.

Uploaded by

Blade Snipes
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 25

Php : Quick Tour

Presented By:
Abhinav Nath Gupta
IT Final Yr (0700113002)
What is Php?

• General purpose scripting language.


• Server side Langauge.
• Easy Connectivity to databases, sockets,etc.
Why Php?

• Easy to use.
• Easy to learn.
• Same in format as general hands on language
like C.
• Highly Flexible.
• Lightweight on Browser.
• Support OOP.
• Open source.
Progress

• Comes to existence in 1994.


• Till now covered over 18 milliom domains.
• Internet Giants like Yahoo and google now
trusting on php.
Using Php

• Php is very simple in application.


Sample Script….
<?php
echo ”Hiii”;
?>
Output:
Hiii
Sample Continues...

Php runs on WAMP server (Windows , Apache MySql


and Php ) on version 5.2.
The Editor used is Macromedia Dreamweaver 8.0.
• Echo(): Used to print the string given in the braces
enclosed with “” or ‘’.
• <?php ?> are the php tags that denotes start and end
of Php code.
Embedding Php

• Php can be embedded with the HTML text.


• The embedding can be done using 4 types of
tags
 <?php ?> : php tags
 <% %>: ASP tags
 <? ?>: Short tags
 < script language = “Php”></script>: via script tags
Php Variables & Constants
• Comments in php are like //.
• For multiline comments use/*” ”*/.
• U can save data directly to the php variables
without defining the data type, e.g,
• The variables in php starts with $.
• $a = 1;
• $a =1.23;
• $a = “hii”;
Cont….

• $a = ‘hii’;
• The = is assignment operator in php.
• The default type is NULL in php.
• You can use ‘’ within “” but viceversa is
prohibited in php.
• Constants are defined using
define(string,value).
Php Internal Data Types
• By default there are 8 data types:
• Boolean: holds true/false.
• Integer: holds integers.
• Float: holds real numbers.
• String: holds text strings.
• Array: hold array of data items.
• Object: user defined programming units.
Cont…..
• Resource: holds data resource.
• NULL: holds Null values.
Operators

There are basically 4 types of operators in php:


• Arithmetic operator(+,-,*,/,%,++,--)
• Assignment operator(=,+=,-=,%=,*=,/=)
• Comparison Operator(==,<=,>=,<>)
• Logical Operator(&&,||,!)
Flow Control
Flow control is done by the use of loops. In php
there are 4 types of loops.
• For loop
for (init; condition; increment)
 {
  code to be executed;
 }
Contd….
• While loop:
while (condition)
 {
  code to be executed;
 }
• Foreach loop:
foreach ($array as $value)
 {
  code to be executed;
 }
Contd…..
• do-while loop:
do
 {
  code to be executed;
 }
while (condition);
Strings In Php
The strings are the collection of alphabets and
are denoted by string variables,
<?php
$txt="Hello World";
echo $txt;
?>

• The concatenation operator(.) is only string


operator in php.
• String Functions
Php is rich in context of string functions.
Contd…
Most commonly used ones are:
• Strlen()
• Strpos()
• Str_repeat()
• Sprintf()
• Strstr()
and many more………….
Arrays in php
Php also supports arrays. In PHP, there are three
kind of arrays
• Numeric array - An array with a numeric index
• Associative array - An array where each ID key
is associated with a value
• Multidimensional array - An array containing
one or more arrays
Contd….
• Numeric Arrays:index starts at 0
$cars=array("Saab","Volvo","BMW","Toyota");

You might also like