SlideShare a Scribd company logo
ChristopherY. Sabado, Mst-CS
Assistant Professor 2
Program Chairperson, BSInfoTech
What is PHP? Write your first PHP Program
What is PHP?
PHP is a server side scripting language. that is used to
develop Static websites or Dynamic websites or Web
applications. PHP stands for Hypertext Pre-processor, that
earlier stood for Personal Home Pages.
PHP scripts can only be interpreted on a server that has
PHP installed.
The client computers accessing the PHP scripts require a
web browser only.
A PHP file contains PHP tags and ends with the extension
“.php”.
What is a Scripting Language?
A script is a set of programming instructions that is interpreted at
runtime.
A scripting language is a language that interprets scripts at
runtime. Scripts are usually embedded into other software
environments.
The purpose of the scripts is usually to enhance the performance
or perform routine tasks for an application.
Server side scripts are interpreted on the server while client side
scripts are interpreted by the client application.
PHP is a server side script that is interpreted on the server while
JavaScript is an example of a client side script that is interpreted
by the client browser. Both PHP and JavaScript can be embedded
into HTML pages.
Introduction to PHP from Beginning to End
What does PHP stand for?
PHP means – Personal Home Page, but it now stands
for the recursive backronym PHP: Hypertext
Preprocessor.
PHP code may be embedded into HTML code, or it can be
used in combination with various web template systems,
web content management system and web frameworks.
A PHP file can also contain tags such as HTML and client
side scripts such as JavaScript.
HTML is an added advantage when learning PHP
Language.You can even learn PHP without knowing HTML
but it’s recommended you at least know the basics of
HTML.
Database management systems DBMS for database
powered applications.
For more advanced topics such as interactive applications
and web services, you will need JavaScript and XML.
The flowchart diagram shown below illustrates the basic architecture of a PHP
web application and how the server handles the requests.
Why use PHP?
You have obviously heard of a number of programming languages out there;
you may be wondering why we would want to use PHP as our poison for the
web programming. Below are some of the compelling reasons.
• PHP is open source and free.
• Short learning curve compared to other languages such as JSP,ASP etc.
• Large community document
• Most web hosting servers support PHP by default unlike other languages such asASP that
need IIS.This makes PHP a cost effective choice.
• PHP is regular updated to keep abreast with the latest technology trends.
• Other benefit that you get with PHP is that it’s a server side scripting language; this
means you only need to install it on the server and client computers requesting for
resources from the server do not need to have PHP installed; only a web browser would be
enough.
• PHP has in built support for working hand in hand with MySQL; this doesn’t
mean you can’t use PHP with other database management systems.You can still use PHP
with • Postgres
• Oracle
• MS SQL Server
• ODBC etc.
What is PHP used for & Market share
In terms of market share, there are over 20 million websites and
application on the internet developed using PHP scripting
language.
This may be attributed to the points raised above;
The diagram below shows some of the popular sites that use PHP
PHP File Extensions
File extension andTags In order for the server to identify our PHP files and scripts, we
must save the file with the “.php” extension. Older PHP file extensions include
• .phtml
• .php3
• .php4
• .php5
• .phps
PHP was designed to work with HTML, and as such, it can be embedded into the HTML
code.
You can create PHP files without any html tags and that is called Pure PHP file .
The server interprets the PHP code and outputs the results as HTML code to the web
browsers.
In order for the server to identify the PHP code from the HTML code, we must always
enclose the PHP code in PHP tags.
A PHP tag starts with the less than symbol followed by the question mark and
then the words “php”.
PHP is a case sensitive language,“VAR” is not the same as “var”.
The PHP tags themselves are not case-sensitive, but it is strongly
recommended that we use lower case letter. The code below illustrates the
above point.
We will be referring to the PHP lines of code as statements. PHP statements
end with a semi colon (;). If you only have one statement, you can omit the
semi colon. If you have more than one statement, then you must end each
line with a semi colon. For the sake of consistency, it is recommended that
you always end your statement(s) with a semi colon. PHP scripts are
executed on the server.The output is returned in form of HTML.
PHP Hello world
The program shown below is a basic PHP application that outputs
the words “HelloWorld!”When viewed in a web browser.
Steps in Saving your PHP file:
Step 1: Make a folder inside C:xampphtdocs
In my example I named my folder lessons,
you follow the same name.
Step 2: In your text editor, click File, then SaveAs,
Step 3: Locate the folder you have just name in my case the Lessons Folder.
Step 4:You must make sure you are inside the HTDOCS folder and inside
the folder you have just made.
Step 5: In the filename section, write the filename Hello.php
Step 6: Click Save.
,
How to run your first PHP Program:
Step 1: Open XAMPP Control Panel
Step 2: Click Start opposite to Apache. In should turn from START to now
STOP and Apache now color Green.
Step 3: Click Close or X
Step 4: Open your web browser (we prefer Google Chrome)
Step 5:Type the following in the URL section:
Take note, you need to replace the lessons word with the name of
your folder that you have created.
Step 6: Press ENTER to display the output.
Summary
• PHP stands for Hypertext pre-processor
• PHP is a server side scripting language.This
means that it is executed on the server.The
client applications do not need to have PHP
installed.
• PHP files are saved with the “.php” file
extension, and the PHP development code is
enclosed in tags.
• PHP is open source and cross platform
PHP Variables
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
<?php
$x = 5985;
var_dump($x);
?>
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
$y = 6;
echo $x + $y;
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
$y = 6;
echo $x - $y;
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
$y = 6;
echo $x * $y;
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
$y = 6;
echo $x / $y;
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
$y = 3;
echo $x ** $y;
?>
</body>
</html>
Introduction to PHP from Beginning to End
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
echo $x;
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
$x = 20;
$x += 100;
echo $x;
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
$x = 50;
$x -= 30;
echo $x;
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
$x = 5;
$x *= 6;
echo $x;
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
$x /= 5;
echo $x;
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
$x = 15;
$x %= 4;
echo $x;
?>
</body>
</html>
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
<!DOCTYPE html>
<html>
<body>
<?php
$x = 100;
$y = "100";
var_dump($x == $y); // returns
true because values are equal
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
$x = 100;
$y = "100";
var_dump($x === $y); //
returns false because types are not
equal
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
$x = 100;
$y = "100";
// returns false because values
are equal
var_dump($x != $y);
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
$x = 100;
$y = "100";
var_dump($x <> $y); // returns
false because values are equal
?>
</body>
</html>
<!DOCTYPE html>
<html>
<bodya>
<?php
$x = 100;
$y = "100";
var_dump($x !== $y); //
returns true because types are not
equal
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
$x = 100;
$y = 50;
var_dump($x > $y); // returns true because $x is
greater than $y
?>
</body>
</html>
Ad

More Related Content

Similar to Introduction to PHP from Beginning to End (20)

Php intro
Php introPhp intro
Php intro
sana mateen
 
lec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoi
lec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoilec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoi
lec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoi
PedakotaPavankumar
 
Php ppt
Php pptPhp ppt
Php ppt
Sasi Kumar
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
Sasi Kumar
 
Php hypertext pre-processor
Php   hypertext pre-processorPhp   hypertext pre-processor
Php hypertext pre-processor
Siddique Ibrahim
 
Php Ppt
Php PptPhp Ppt
Php Ppt
vsnmurthy
 
Php
PhpPhp
Php
Vineet Vats
 
Hypertext preprocessing notes preparation
Hypertext preprocessing notes preparationHypertext preprocessing notes preparation
Hypertext preprocessing notes preparation
harleensingh985
 
01 Php Introduction
01 Php Introduction01 Php Introduction
01 Php Introduction
Geshan Manandhar
 
PHP Hub in Ambala ! Batra Computer Centre
PHP Hub in Ambala ! Batra Computer CentrePHP Hub in Ambala ! Batra Computer Centre
PHP Hub in Ambala ! Batra Computer Centre
jatin batra
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
Uma Sam
 
PHP ITCS 323
PHP ITCS 323PHP ITCS 323
PHP ITCS 323
Sleepy Head
 
Php
PhpPhp
Php
Nadhi ya
 
Basic php
Basic phpBasic php
Basic php
salissal
 
PhP Training Institute In Delhi
PhP Training Institute In DelhiPhP Training Institute In Delhi
PhP Training Institute In Delhi
DivyaSharma84779
 
PHP.pptx is the Best Explanation of ppts
PHP.pptx is the Best Explanation of pptsPHP.pptx is the Best Explanation of ppts
PHP.pptx is the Best Explanation of ppts
AkhileshPansare
 
Word press
Word pressWord press
Word press
Brian Lucas
 
Php unit i
Php unit iPhp unit i
Php unit i
BagavathiLakshmi
 
Php1
Php1Php1
Php1
poornima sugumaran
 
unitI-Introduction to php.pptx
unitI-Introduction to php.pptxunitI-Introduction to php.pptx
unitI-Introduction to php.pptx
nehasahuji
 

Recently uploaded (20)

Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
The Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdfThe Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdf
Precisely
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...
BookNet Canada
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
Financial Services Technology Summit 2025
Financial Services Technology Summit 2025Financial Services Technology Summit 2025
Financial Services Technology Summit 2025
Ray Bugg
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Does Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should KnowDoes Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should Know
Pornify CC
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
The Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdfThe Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdf
Precisely
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...
BookNet Canada
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
Financial Services Technology Summit 2025
Financial Services Technology Summit 2025Financial Services Technology Summit 2025
Financial Services Technology Summit 2025
Ray Bugg
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Does Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should KnowDoes Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should Know
Pornify CC
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Ad

Introduction to PHP from Beginning to End

  • 1. ChristopherY. Sabado, Mst-CS Assistant Professor 2 Program Chairperson, BSInfoTech What is PHP? Write your first PHP Program
  • 2. What is PHP? PHP is a server side scripting language. that is used to develop Static websites or Dynamic websites or Web applications. PHP stands for Hypertext Pre-processor, that earlier stood for Personal Home Pages. PHP scripts can only be interpreted on a server that has PHP installed. The client computers accessing the PHP scripts require a web browser only. A PHP file contains PHP tags and ends with the extension “.php”.
  • 3. What is a Scripting Language? A script is a set of programming instructions that is interpreted at runtime. A scripting language is a language that interprets scripts at runtime. Scripts are usually embedded into other software environments. The purpose of the scripts is usually to enhance the performance or perform routine tasks for an application. Server side scripts are interpreted on the server while client side scripts are interpreted by the client application. PHP is a server side script that is interpreted on the server while JavaScript is an example of a client side script that is interpreted by the client browser. Both PHP and JavaScript can be embedded into HTML pages.
  • 5. What does PHP stand for? PHP means – Personal Home Page, but it now stands for the recursive backronym PHP: Hypertext Preprocessor. PHP code may be embedded into HTML code, or it can be used in combination with various web template systems, web content management system and web frameworks.
  • 6. A PHP file can also contain tags such as HTML and client side scripts such as JavaScript. HTML is an added advantage when learning PHP Language.You can even learn PHP without knowing HTML but it’s recommended you at least know the basics of HTML. Database management systems DBMS for database powered applications. For more advanced topics such as interactive applications and web services, you will need JavaScript and XML.
  • 7. The flowchart diagram shown below illustrates the basic architecture of a PHP web application and how the server handles the requests.
  • 8. Why use PHP? You have obviously heard of a number of programming languages out there; you may be wondering why we would want to use PHP as our poison for the web programming. Below are some of the compelling reasons. • PHP is open source and free. • Short learning curve compared to other languages such as JSP,ASP etc. • Large community document • Most web hosting servers support PHP by default unlike other languages such asASP that need IIS.This makes PHP a cost effective choice. • PHP is regular updated to keep abreast with the latest technology trends. • Other benefit that you get with PHP is that it’s a server side scripting language; this means you only need to install it on the server and client computers requesting for resources from the server do not need to have PHP installed; only a web browser would be enough. • PHP has in built support for working hand in hand with MySQL; this doesn’t mean you can’t use PHP with other database management systems.You can still use PHP with • Postgres • Oracle • MS SQL Server • ODBC etc.
  • 9. What is PHP used for & Market share In terms of market share, there are over 20 million websites and application on the internet developed using PHP scripting language. This may be attributed to the points raised above; The diagram below shows some of the popular sites that use PHP
  • 10. PHP File Extensions File extension andTags In order for the server to identify our PHP files and scripts, we must save the file with the “.php” extension. Older PHP file extensions include • .phtml • .php3 • .php4 • .php5 • .phps PHP was designed to work with HTML, and as such, it can be embedded into the HTML code. You can create PHP files without any html tags and that is called Pure PHP file . The server interprets the PHP code and outputs the results as HTML code to the web browsers. In order for the server to identify the PHP code from the HTML code, we must always enclose the PHP code in PHP tags.
  • 11. A PHP tag starts with the less than symbol followed by the question mark and then the words “php”. PHP is a case sensitive language,“VAR” is not the same as “var”. The PHP tags themselves are not case-sensitive, but it is strongly recommended that we use lower case letter. The code below illustrates the above point. We will be referring to the PHP lines of code as statements. PHP statements end with a semi colon (;). If you only have one statement, you can omit the semi colon. If you have more than one statement, then you must end each line with a semi colon. For the sake of consistency, it is recommended that you always end your statement(s) with a semi colon. PHP scripts are executed on the server.The output is returned in form of HTML.
  • 12. PHP Hello world The program shown below is a basic PHP application that outputs the words “HelloWorld!”When viewed in a web browser.
  • 13. Steps in Saving your PHP file: Step 1: Make a folder inside C:xampphtdocs In my example I named my folder lessons, you follow the same name. Step 2: In your text editor, click File, then SaveAs,
  • 14. Step 3: Locate the folder you have just name in my case the Lessons Folder. Step 4:You must make sure you are inside the HTDOCS folder and inside the folder you have just made. Step 5: In the filename section, write the filename Hello.php Step 6: Click Save. ,
  • 15. How to run your first PHP Program: Step 1: Open XAMPP Control Panel Step 2: Click Start opposite to Apache. In should turn from START to now STOP and Apache now color Green. Step 3: Click Close or X
  • 16. Step 4: Open your web browser (we prefer Google Chrome) Step 5:Type the following in the URL section: Take note, you need to replace the lessons word with the name of your folder that you have created. Step 6: Press ENTER to display the output.
  • 17. Summary • PHP stands for Hypertext pre-processor • PHP is a server side scripting language.This means that it is executed on the server.The client applications do not need to have PHP installed. • PHP files are saved with the “.php” file extension, and the PHP development code is enclosed in tags. • PHP is open source and cross platform
  • 34. <!DOCTYPE html> <html> <body> <?php $x = 10; $y = 6; echo $x + $y; ?> </body> </html>
  • 35. <!DOCTYPE html> <html> <body> <?php $x = 10; $y = 6; echo $x - $y; ?> </body> </html>
  • 36. <!DOCTYPE html> <html> <body> <?php $x = 10; $y = 6; echo $x * $y; ?> </body> </html>
  • 37. <!DOCTYPE html> <html> <body> <?php $x = 10; $y = 6; echo $x / $y; ?> </body> </html>
  • 38. <!DOCTYPE html> <html> <body> <?php $x = 10; $y = 3; echo $x ** $y; ?> </body> </html>
  • 40. <!DOCTYPE html> <html> <body> <?php $x = 10; echo $x; ?> </body> </html>
  • 41. <!DOCTYPE html> <html> <body> <?php $x = 20; $x += 100; echo $x; ?> </body> </html>
  • 42. <!DOCTYPE html> <html> <body> <?php $x = 50; $x -= 30; echo $x; ?> </body> </html>
  • 43. <!DOCTYPE html> <html> <body> <?php $x = 5; $x *= 6; echo $x; ?> </body> </html>
  • 44. <!DOCTYPE html> <html> <body> <?php $x = 10; $x /= 5; echo $x; ?> </body> </html>
  • 45. <!DOCTYPE html> <html> <body> <?php $x = 15; $x %= 4; echo $x; ?> </body> </html>
  • 48. <!DOCTYPE html> <html> <body> <?php $x = 100; $y = "100"; var_dump($x == $y); // returns true because values are equal ?> </body> </html>
  • 49. <!DOCTYPE html> <html> <body> <?php $x = 100; $y = "100"; var_dump($x === $y); // returns false because types are not equal ?> </body> </html>
  • 50. <!DOCTYPE html> <html> <body> <?php $x = 100; $y = "100"; // returns false because values are equal var_dump($x != $y); ?> </body> </html>
  • 51. <!DOCTYPE html> <html> <body> <?php $x = 100; $y = "100"; var_dump($x <> $y); // returns false because values are equal ?> </body> </html>
  • 52. <!DOCTYPE html> <html> <bodya> <?php $x = 100; $y = "100"; var_dump($x !== $y); // returns true because types are not equal ?> </body> </html>
  • 53. <!DOCTYPE html> <html> <body> <?php $x = 100; $y = 50; var_dump($x > $y); // returns true because $x is greater than $y ?> </body> </html>
  翻译: