SlideShare a Scribd company logo
1 of 16
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

What's hot (20)

01 Php Introduction
01 Php Introduction01 Php Introduction
01 Php Introduction
 
Php tutorial
Php  tutorialPhp  tutorial
Php tutorial
 
Php basics
Php basicsPhp basics
Php basics
 
Php
PhpPhp
Php
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
Php introduction
Php introductionPhp introduction
Php introduction
 
php
phpphp
php
 
3. Java Script
3. Java Script3. Java Script
3. Java Script
 
Javascript
JavascriptJavascript
Javascript
 
What Is Php
What Is PhpWhat Is Php
What Is Php
 
Html basics
Html basicsHtml basics
Html basics
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Php cookies
Php cookiesPhp cookies
Php cookies
 
Javascript essentials
Javascript essentialsJavascript essentials
Javascript essentials
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
 
PHP.ppt
PHP.pptPHP.ppt
PHP.ppt
 

Viewers also liked

Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHPBradley Holt
 
State of the Word 2011
State of the Word 2011State of the Word 2011
State of the Word 2011photomatt
 
Lessons Learned - Building YDN
Lessons Learned - Building YDNLessons Learned - Building YDN
Lessons Learned - Building YDNDan Theurer
 
Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04Spy Seat
 
100 PHP question and answer
100 PHP  question and answer100 PHP  question and answer
100 PHP question and answerSandip Murari
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery PresentationRod Johnson
 
Top 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and AnswersTop 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and AnswersVineet Kumar Saini
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginningAnis Ahmad
 
Implementing DDD Concepts in PHP
Implementing DDD Concepts in PHPImplementing DDD Concepts in PHP
Implementing DDD Concepts in PHPSteve Rhoades
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutesSimon Willison
 
Class 6 - PHP Web Programming
Class 6 - PHP Web ProgrammingClass 6 - PHP Web Programming
Class 6 - PHP Web ProgrammingAhmed Swilam
 
Top 100 PHP Questions and Answers
Top 100 PHP Questions and AnswersTop 100 PHP Questions and Answers
Top 100 PHP Questions and Answersiimjobs and hirist
 
Students, Computers and Learning: Making the Connection (Andreas Schleiche...
Students, Computers and Learning: Making the Connection  (Andreas Schleiche...Students, Computers and Learning: Making the Connection  (Andreas Schleiche...
Students, Computers and Learning: Making the Connection (Andreas Schleiche...EduSkills OECD
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript ProgrammingSehwan Noh
 

Viewers also liked (20)

Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
State of the Word 2011
State of the Word 2011State of the Word 2011
State of the Word 2011
 
Lessons Learned - Building YDN
Lessons Learned - Building YDNLessons Learned - Building YDN
Lessons Learned - Building YDN
 
PHP - Introduction to PHP Functions
PHP -  Introduction to PHP FunctionsPHP -  Introduction to PHP Functions
PHP - Introduction to PHP Functions
 
Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04
 
Introduction to JavaScript Programming
Introduction to JavaScript ProgrammingIntroduction to JavaScript Programming
Introduction to JavaScript Programming
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
100 PHP question and answer
100 PHP  question and answer100 PHP  question and answer
100 PHP question and answer
 
Practice exam php
Practice exam phpPractice exam php
Practice exam php
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery Presentation
 
Top 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and AnswersTop 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and Answers
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
 
Implementing DDD Concepts in PHP
Implementing DDD Concepts in PHPImplementing DDD Concepts in PHP
Implementing DDD Concepts in PHP
 
1000+ php questions
1000+ php questions1000+ php questions
1000+ php questions
 
PHP - Introduction to PHP
PHP -  Introduction to PHPPHP -  Introduction to PHP
PHP - Introduction to PHP
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 
Class 6 - PHP Web Programming
Class 6 - PHP Web ProgrammingClass 6 - PHP Web Programming
Class 6 - PHP Web Programming
 
Top 100 PHP Questions and Answers
Top 100 PHP Questions and AnswersTop 100 PHP Questions and Answers
Top 100 PHP Questions and Answers
 
Students, Computers and Learning: Making the Connection (Andreas Schleiche...
Students, Computers and Learning: Making the Connection  (Andreas Schleiche...Students, Computers and Learning: Making the Connection  (Andreas Schleiche...
Students, Computers and Learning: Making the Connection (Andreas Schleiche...
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 

Similar to Introduction to PHP

PHP Arrays - indexed and associative array.
PHP Arrays - indexed and associative array. PHP Arrays - indexed and associative array.
PHP Arrays - indexed and associative array. wahidullah mudaser
 
Introducation to php for beginners
Introducation to php for beginners Introducation to php for beginners
Introducation to php for beginners musrath mohammad
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHPNat Weerawan
 
Cakefest 2010: API Development
Cakefest 2010: API DevelopmentCakefest 2010: API Development
Cakefest 2010: API DevelopmentAndrew Curioso
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkDirk Haun
 
Intro to php
Intro to phpIntro to php
Intro to phpSp Singh
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkBo-Yi Wu
 
FYBSC IT Web Programming Unit IV PHP and MySQL
FYBSC IT Web Programming Unit IV  PHP and MySQLFYBSC IT Web Programming Unit IV  PHP and MySQL
FYBSC IT Web Programming Unit IV PHP and MySQLArti Parab Academics
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kianphelios
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with PerlDave Cross
 

Similar to Introduction to PHP (20)

PHP Arrays - indexed and associative array.
PHP Arrays - indexed and associative array. PHP Arrays - indexed and associative array.
PHP Arrays - indexed and associative array.
 
Php with my sql
Php with my sqlPhp with my sql
Php with my sql
 
Php
PhpPhp
Php
 
Introducation to php for beginners
Introducation to php for beginners Introducation to php for beginners
Introducation to php for beginners
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 
PHP-Part1
PHP-Part1PHP-Part1
PHP-Part1
 
Cakefest 2010: API Development
Cakefest 2010: API DevelopmentCakefest 2010: API Development
Cakefest 2010: API Development
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
Tutorial_4_PHP
Tutorial_4_PHPTutorial_4_PHP
Tutorial_4_PHP
 
Tutorial_4_PHP
Tutorial_4_PHPTutorial_4_PHP
Tutorial_4_PHP
 
Tutorial_4_PHP
Tutorial_4_PHPTutorial_4_PHP
Tutorial_4_PHP
 
Tutorial_4_PHP
Tutorial_4_PHPTutorial_4_PHP
Tutorial_4_PHP
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
Intro to php
Intro to phpIntro to php
Intro to php
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
Basic php 5
Basic php 5Basic php 5
Basic php 5
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
FYBSC IT Web Programming Unit IV PHP and MySQL
FYBSC IT Web Programming Unit IV  PHP and MySQLFYBSC IT Web Programming Unit IV  PHP and MySQL
FYBSC IT Web Programming Unit IV PHP and MySQL
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kian
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 

More from Collaboration Technologies (15)

Introduction to Core Java Programming
Introduction to Core Java ProgrammingIntroduction to Core Java Programming
Introduction to Core Java Programming
 
Introduction to Database SQL & PL/SQL
Introduction to Database SQL & PL/SQLIntroduction to Database SQL & PL/SQL
Introduction to Database SQL & PL/SQL
 
Introduction to Advanced Javascript
Introduction to Advanced JavascriptIntroduction to Advanced Javascript
Introduction to Advanced Javascript
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Introduction to Bootstrap
Introduction to BootstrapIntroduction to Bootstrap
Introduction to Bootstrap
 
Introduction to Hibernate Framework
Introduction to Hibernate FrameworkIntroduction to Hibernate Framework
Introduction to Hibernate Framework
 
Introduction to HTML4
Introduction to HTML4Introduction to HTML4
Introduction to HTML4
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
 
Introduction to JPA Framework
Introduction to JPA FrameworkIntroduction to JPA Framework
Introduction to JPA Framework
 
Introduction to Perl Programming
Introduction to Perl ProgrammingIntroduction to Perl Programming
Introduction to Perl Programming
 
Introduction to Python Basics Programming
Introduction to Python Basics ProgrammingIntroduction to Python Basics Programming
Introduction to Python Basics Programming
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Introduction to Struts 2
Introduction to Struts 2Introduction to Struts 2
Introduction to Struts 2
 
Introduction to JSON & AJAX
Introduction to JSON & AJAXIntroduction to JSON & AJAX
Introduction to JSON & AJAX
 
Introduction to Node.JS
Introduction to Node.JSIntroduction to Node.JS
Introduction to Node.JS
 

Recently uploaded

Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 

Recently uploaded (20)

Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 

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 = "jim@demo.com"; 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