SlideShare a Scribd company logo
Introduction to PHP
www.collaborationtech.co.in
Bengaluru INDIA
Presentation By
Ramananda M.S Rao
Content
Content
Introduction
Get Started
Variables & Data Types
Control Structure
Operators and Expressions
Strings and Arrays
Functions
Local & Global Variables in Functions
Files Handling and Globbing
Exception Handling
References
OOPS Concepts
Collections
Regular Expressions
PHP Utility Programs
Working with HTTP and Browser
Working with MYSQL and PHP
Working with PEAR
Application Development Projects
About Us
www.collaborationtech.co.in
Introduction
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 is free to download and use
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"
www.collaborationtech.co.in
Get Started
<html>
<head>
<title>Hello World</title>
</head>
<body>
<?php
$a="Hello";
$b="World";
echo $a,$b;
?>
</body>
</html>
www.collaborationtech.co.in
Control Structure
 Control structure are usually based on condition and therefore always have condition associated with them
They check the status of these conditions ,which can be either true or false .
<html>
<head><title></title></head>
<body>
<?php
$hour = date( "G" );$year = date( "Y" );
if ( $hour >= 5 && $hour < 12 )
{echo "<h1>Good morning!</h1>";}
elseif( $hour >= 12 && $hour < 18 )
{echo "<h1>Good afternoon!</h1>";}
elseif ( $hour >= 18 && $hour < 22 )
{echo "<h1>Good evening!</h1>";}
Else {echo "<h1>Good night!</h1>";}
$leapYear = false;
if ((( $year % 4 == 0 )&&( $year % 100 != 0))||($year % 400 == 0))
$leapYear = true;
echo "<p>Did you know that $year is" , ( $leapYear ? "" : " not" ) , " a leap
year?</p>";
?>
</body>
</html>
www.collaborationtech.co.in
Control Structure
<html>
<head>
<title> Factorial </title>
</head>
<body>
<h1> Factorial </h1>
<?php
$num=4;
for($i=1;$i<$num;$i++)
{
$fact=1;
for($j=1;$j<=$num;$j++)
{
$fact*=$i*$j;
echo $fact,"<br>";
}
}
?>
</body>
</html>
www.collaborationtech.co.in
Strings
<html>
<head><title>Lower Upper Case</title></head>
<body>
<?php
$myString = "hello, world!";
echo strtolower($myString), "<br>"; // Displays ‘hello, world!’
echo strtoupper($myString), "<br>"; // Displays ‘HELLO, WORLD!’
echo ucfirst($myString), "<br>"; // Displays ‘Hello, world!’
//echo lcfirst($myString), "<br>"; // Displays ‘hello, World!’
echo ucwords($myString), "<br>"; // Displays ‘Hello, World!’
?>
</body>
</html>
www.collaborationtech.co.in
Functions
 PHP functions are similar to other programming languages. A function is a piece of code which takes one more
input in the form of parameter and does some processing and returns a value.
Example:
<html>
<head>
<title> Function </title>
</head>
<body>
<h1> Function </h1>
<?php
function hello()
{echo "Hello, world!<br/>";}
hello();
?>
</body>
</html>
www.collaborationtech.co.in
File Handling
 File handling is a very important part of any web application. Many times you need to open a file and process the
file according to the specific requirement.
Example:
<html>
<head>
<title>Reading a File</title>
</head>
<body>
<?php
$handle=fopen("file.txt","r");
while(!feof($handle))
{
$text=fgets($handle);
echo $text,"<br>";
}
?></body></html>
file.txt
Hello, Collaba.
How r u?
PHP is cool, keep it up..
www.collaborationtech.co.in
File Handling
<html>
<head>
<title>File Exist or Not</title>
</head>
<body>
<?php
$filename="file.txt";
if(file_exists($filename))
{
$data=file($filename);
foreach($data as $number=>$line)
{echo "Line $number: ", $line, "<br>";}}
else
{echo "The file $filename does not exist";}
?>
</body>
</html>
www.collaborationtech.co.in
File Handling
<html>
<head>
<title>Copying File</title>
</head>
<body>
<?php
$file='file.txt';
$copy='filecopy.txt';
if(copy($file,$copy))
{echo "$file is successfuly copied";}
else
{echo "$file could not be copied";}
?>
</body>
</html>
www.collaborationtech.co.in
OOPS
<!DOCTYPE html>
<html lang="en">
<head>
<title> A Simple Car Simulator </title>
<link rel="stylesheet" type="text/css" href="common.css" />
</head>
<body>
<h1> A Simple Car Simulator </h1>
<?php
class Car
{public $color;public $manufacturer;public $model;private $_speed = 0;
public function accelerate()
{if ( $this-> _speed >= 100 ) return false;$this-> _speed += 10;return true;}
public function brake()
{if ( $this-> _speed <= 0 ) return false;$this-> _speed -= 10;return true;}
www.collaborationtech.co.in
OOPS
public function getSpeed()
{return $this-> _speed;}}
$myCar = new Car();
$myCar-> color = "red";
$myCar-> manufacturer = "Volkswagen";
$myCar-> model = "Beetle";
echo " <p> I’m driving a $myCar->color $myCar->manufacturer $myCar->model. </p> ";
echo " <p> Stepping on the gas... <br /> ";
while ( $myCar-> accelerate() )
{echo "Current speed: " . $myCar-> getSpeed() . " mph <br /> ";}
echo " </p> <p> Top speed! Slowing down... <br /> ";
while ( $myCar-> brake() )
{echo "Current speed: " . $myCar-> getSpeed() . " mph <br /> ";}
echo " </p> <p> Stopped! </p> ";
?>
</body>
</html>
www.collaborationtech.co.in
Regular Expressions
 Regular expressions are nothing more than a sequence or pattern of characters itself. They provide
the foundation for pattern-matching functionality.
Example:
<?php
echo preg_match( "/world/", "Hello, world!", $match ), "<br />";
echo $match[0], "<br />";
?>
Example:
<?php
//Code to check the email using Posix compatible regular expression
$pattern = "^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+.[a-zA-Z.]{2,5}$";
$email = "jim@demo.com";
if (eregi($pattern,$email))
echo "Match";
else
echo "Not match";
?>
www.collaborationtech.co.in
Follow us on Social
Facebook: https://www.facebook.com/collaborationtechnologies/
Twitter : https://twitter.com/collaboration09
Google Plus : https://plus.google.com/100704494006819853579
LinkedIn : https://www.linkedin.com/in/ramananda-rao-a2012545
Instagram : https://instagram.com/collaborationtechnologies
YouTube :
https://www.youtube.com/channel/UCm9nK56LRbWSqcYWbzs8CUg
Skype : facebook:ramananda.rao.7
WhatsApp : +91 9886272445
www.collaborationtech.co.in
THANK YOU
About Us

More Related Content

PPT
Introduction To PHP
PPT
01 Php Introduction
PPT
Php Presentation
PPSX
Php using variables-operators
PPT
Introduction to PHP
PPT
PHP POWERPOINT SLIDES
PPTX
Loops PHP 04
PPT
PHP - DataType,Variable,Constant,Operators,Array,Include and require
Introduction To PHP
01 Php Introduction
Php Presentation
Php using variables-operators
Introduction to PHP
PHP POWERPOINT SLIDES
Loops PHP 04
PHP - DataType,Variable,Constant,Operators,Array,Include and require

What's hot (20)

PPTX
Basics of the Web Platform
PDF
Php introduction
PPT
Php Lecture Notes
PDF
Web Development with Python and Django
PPTX
Javascript
PPTX
PPTX
Basic HTML
PPT
Chapter 02 php basic syntax
PDF
Web Development Course: PHP lecture 1
PDF
An Introduction of Node Package Manager (NPM)
PDF
Introduction to php
PPTX
Java script
PPT
Php forms
PDF
PDF
ORM in Django
PPTX
Php basics
PPTX
Form Handling using PHP
PPT
PHP complete reference with database concepts for beginners
Basics of the Web Platform
Php introduction
Php Lecture Notes
Web Development with Python and Django
Javascript
Basic HTML
Chapter 02 php basic syntax
Web Development Course: PHP lecture 1
An Introduction of Node Package Manager (NPM)
Introduction to php
Java script
Php forms
ORM in Django
Php basics
Form Handling using PHP
PHP complete reference with database concepts for beginners
Ad

Viewers also liked (19)

PDF
Introduction to PHP
PDF
State of the Word 2011
PPT
Lessons Learned - Building YDN
PPT
PHP - Introduction to PHP Functions
PPTX
Introduction to JavaScript Programming
PPTX
Introduction to jQuery
DOCX
100 PHP question and answer
PDF
Practice exam php
PPTX
jQuery Presentation
PDF
Top 100 PHP Interview Questions and Answers
PPTX
jQuery from the very beginning
PPTX
Implementing DDD Concepts in PHP
DOCX
1000+ php questions
PPT
PHP - Introduction to PHP
PDF
Learning jQuery in 30 minutes
PPT
Class 6 - PHP Web Programming
PDF
Top 100 PHP Questions and Answers
PPTX
Students, Computers and Learning: Making the Connection (Andreas Schleiche...
PDF
JavaScript Programming
Introduction to PHP
State of the Word 2011
Lessons Learned - Building YDN
PHP - Introduction to PHP Functions
Introduction to JavaScript Programming
Introduction to jQuery
100 PHP question and answer
Practice exam php
jQuery Presentation
Top 100 PHP Interview Questions and Answers
jQuery from the very beginning
Implementing DDD Concepts in PHP
1000+ php questions
PHP - Introduction to PHP
Learning jQuery in 30 minutes
Class 6 - PHP Web Programming
Top 100 PHP Questions and Answers
Students, Computers and Learning: Making the Connection (Andreas Schleiche...
JavaScript Programming
Ad

Similar to Introduction to PHP (20)

PDF
PHP Arrays - indexed and associative array.
PPT
Php with my sql
PPT
Introducation to php for beginners
KEY
GettingStartedWithPHP
PDF
PHP-Part1
PPTX
php is the most important programming language
PPTX
Cakefest 2010: API Development
PPTX
The basics of php for engeneering students
PDF
Tutorial_4_PHP
PDF
Tutorial_4_PHP
PDF
Tutorial_4_PHP
PDF
Tutorial_4_PHP
PPTX
PHP Basics
PPT
Intro to php
PPT
Php mysql
DOCX
Basic php 5
ODP
CodeIgniter PHP MVC Framework
PPTX
FYBSC IT Web Programming Unit IV PHP and MySQL
PPT
P H P Part I I, By Kian
PHP Arrays - indexed and associative array.
Php with my sql
Introducation to php for beginners
GettingStartedWithPHP
PHP-Part1
php is the most important programming language
Cakefest 2010: API Development
The basics of php for engeneering students
Tutorial_4_PHP
Tutorial_4_PHP
Tutorial_4_PHP
Tutorial_4_PHP
PHP Basics
Intro to php
Php mysql
Basic php 5
CodeIgniter PHP MVC Framework
FYBSC IT Web Programming Unit IV PHP and MySQL
P H P Part I I, By Kian

More from Collaboration Technologies (15)

PPTX
Introduction to Core Java Programming
PPTX
Introduction to Database SQL & PL/SQL
PPTX
Introduction to Advanced Javascript
PPTX
Introduction to AngularJS
PPTX
Introduction to Bootstrap
PPTX
Introduction to Hibernate Framework
PPTX
Introduction to HTML4
PPTX
Introduction to HTML5
PPTX
Introduction to JPA Framework
PPTX
Introduction to Perl Programming
PPTX
Introduction to Python Basics Programming
PPTX
Introduction to Spring Framework
PPTX
Introduction to Struts 2
PPTX
Introduction to JSON & AJAX
PPTX
Introduction to Node.JS
Introduction to Core Java Programming
Introduction to Database SQL & PL/SQL
Introduction to Advanced Javascript
Introduction to AngularJS
Introduction to Bootstrap
Introduction to Hibernate Framework
Introduction to HTML4
Introduction to HTML5
Introduction to JPA Framework
Introduction to Perl Programming
Introduction to Python Basics Programming
Introduction to Spring Framework
Introduction to Struts 2
Introduction to JSON & AJAX
Introduction to Node.JS

Recently uploaded (20)

PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
How AI Agents Improve Data Accuracy and Consistency in Due Diligence.pdf
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Enable Enterprise-Ready Security on IBM i Systems.pdf
PDF
REPORT: Heating appliances market in Poland 2024
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Reimagining Insurance: Connected Data for Confident Decisions.pdf
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
PPTX
CroxyProxy Instagram Access id login.pptx
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PPTX
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
NewMind AI Weekly Chronicles - August'25 Week I
How AI Agents Improve Data Accuracy and Consistency in Due Diligence.pdf
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Enable Enterprise-Ready Security on IBM i Systems.pdf
REPORT: Heating appliances market in Poland 2024
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Reimagining Insurance: Connected Data for Confident Decisions.pdf
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
CroxyProxy Instagram Access id login.pptx
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
Understanding_Digital_Forensics_Presentation.pptx
GamePlan Trading System Review: Professional Trader's Honest Take
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx

Introduction to PHP

  • 1. Introduction to PHP www.collaborationtech.co.in Bengaluru INDIA Presentation By Ramananda M.S Rao
  • 2. Content Content Introduction Get Started Variables & Data Types Control Structure Operators and Expressions Strings and Arrays Functions Local & Global Variables in Functions Files Handling and Globbing Exception Handling References OOPS Concepts Collections Regular Expressions PHP Utility Programs Working with HTTP and Browser Working with MYSQL and PHP Working with PEAR Application Development Projects About Us www.collaborationtech.co.in
  • 3. Introduction 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 is free to download and use 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" www.collaborationtech.co.in
  • 5. Control Structure  Control structure are usually based on condition and therefore always have condition associated with them They check the status of these conditions ,which can be either true or false . <html> <head><title></title></head> <body> <?php $hour = date( "G" );$year = date( "Y" ); if ( $hour >= 5 && $hour < 12 ) {echo "<h1>Good morning!</h1>";} elseif( $hour >= 12 && $hour < 18 ) {echo "<h1>Good afternoon!</h1>";} elseif ( $hour >= 18 && $hour < 22 ) {echo "<h1>Good evening!</h1>";} Else {echo "<h1>Good night!</h1>";} $leapYear = false; if ((( $year % 4 == 0 )&&( $year % 100 != 0))||($year % 400 == 0)) $leapYear = true; echo "<p>Did you know that $year is" , ( $leapYear ? "" : " not" ) , " a leap year?</p>"; ?> </body> </html> www.collaborationtech.co.in
  • 6. Control Structure <html> <head> <title> Factorial </title> </head> <body> <h1> Factorial </h1> <?php $num=4; for($i=1;$i<$num;$i++) { $fact=1; for($j=1;$j<=$num;$j++) { $fact*=$i*$j; echo $fact,"<br>"; } } ?> </body> </html> www.collaborationtech.co.in
  • 7. Strings <html> <head><title>Lower Upper Case</title></head> <body> <?php $myString = "hello, world!"; echo strtolower($myString), "<br>"; // Displays ‘hello, world!’ echo strtoupper($myString), "<br>"; // Displays ‘HELLO, WORLD!’ echo ucfirst($myString), "<br>"; // Displays ‘Hello, world!’ //echo lcfirst($myString), "<br>"; // Displays ‘hello, World!’ echo ucwords($myString), "<br>"; // Displays ‘Hello, World!’ ?> </body> </html> www.collaborationtech.co.in
  • 8. Functions  PHP functions are similar to other programming languages. A function is a piece of code which takes one more input in the form of parameter and does some processing and returns a value. Example: <html> <head> <title> Function </title> </head> <body> <h1> Function </h1> <?php function hello() {echo "Hello, world!<br/>";} hello(); ?> </body> </html> www.collaborationtech.co.in
  • 9. File Handling  File handling is a very important part of any web application. Many times you need to open a file and process the file according to the specific requirement. Example: <html> <head> <title>Reading a File</title> </head> <body> <?php $handle=fopen("file.txt","r"); while(!feof($handle)) { $text=fgets($handle); echo $text,"<br>"; } ?></body></html> file.txt Hello, Collaba. How r u? PHP is cool, keep it up.. www.collaborationtech.co.in
  • 10. File Handling <html> <head> <title>File Exist or Not</title> </head> <body> <?php $filename="file.txt"; if(file_exists($filename)) { $data=file($filename); foreach($data as $number=>$line) {echo "Line $number: ", $line, "<br>";}} else {echo "The file $filename does not exist";} ?> </body> </html> www.collaborationtech.co.in
  • 11. File Handling <html> <head> <title>Copying File</title> </head> <body> <?php $file='file.txt'; $copy='filecopy.txt'; if(copy($file,$copy)) {echo "$file is successfuly copied";} else {echo "$file could not be copied";} ?> </body> </html> www.collaborationtech.co.in
  • 12. OOPS <!DOCTYPE html> <html lang="en"> <head> <title> A Simple Car Simulator </title> <link rel="stylesheet" type="text/css" href="common.css" /> </head> <body> <h1> A Simple Car Simulator </h1> <?php class Car {public $color;public $manufacturer;public $model;private $_speed = 0; public function accelerate() {if ( $this-> _speed >= 100 ) return false;$this-> _speed += 10;return true;} public function brake() {if ( $this-> _speed <= 0 ) return false;$this-> _speed -= 10;return true;} www.collaborationtech.co.in
  • 13. OOPS public function getSpeed() {return $this-> _speed;}} $myCar = new Car(); $myCar-> color = "red"; $myCar-> manufacturer = "Volkswagen"; $myCar-> model = "Beetle"; echo " <p> I’m driving a $myCar->color $myCar->manufacturer $myCar->model. </p> "; echo " <p> Stepping on the gas... <br /> "; while ( $myCar-> accelerate() ) {echo "Current speed: " . $myCar-> getSpeed() . " mph <br /> ";} echo " </p> <p> Top speed! Slowing down... <br /> "; while ( $myCar-> brake() ) {echo "Current speed: " . $myCar-> getSpeed() . " mph <br /> ";} echo " </p> <p> Stopped! </p> "; ?> </body> </html> www.collaborationtech.co.in
  • 14. Regular Expressions  Regular expressions are nothing more than a sequence or pattern of characters itself. They provide the foundation for pattern-matching functionality. Example: <?php echo preg_match( "/world/", "Hello, world!", $match ), "<br />"; echo $match[0], "<br />"; ?> Example: <?php //Code to check the email using Posix compatible regular expression $pattern = "^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+.[a-zA-Z.]{2,5}$"; $email = "[email protected]"; if (eregi($pattern,$email)) echo "Match"; else echo "Not match"; ?> www.collaborationtech.co.in
  • 15. Follow us on Social Facebook: https://www.facebook.com/collaborationtechnologies/ Twitter : https://twitter.com/collaboration09 Google Plus : https://plus.google.com/100704494006819853579 LinkedIn : https://www.linkedin.com/in/ramananda-rao-a2012545 Instagram : https://instagram.com/collaborationtechnologies YouTube : https://www.youtube.com/channel/UCm9nK56LRbWSqcYWbzs8CUg Skype : facebook:ramananda.rao.7 WhatsApp : +91 9886272445 www.collaborationtech.co.in THANK YOU