SlideShare a Scribd company logo
1 of 21
Introduction
Ayub hussein abdulle
Msc in CSE
University of somalia (UNISO)
PHP & MySQL
 IntroductionIntroduction
 Text Book/Reference MaterialsText Book/Reference Materials
 ContentsContents
 AssessmentAssessment
 QuizQuiz 10%10%
 Ass/PRAss/PR 20%20%
 Mid Quarter ExamMid Quarter Exam 30%30%
 Final ExamFinal Exam 40%40%
 Rules of the classRules of the class
 Mobiles on “Silent” please MSCMobiles on “Silent” please MSC – CSE, Lecturer: Engr. Ayub– CSE, Lecturer: Engr. Ayub
HusseinHussein
 ““No class within class” pleaseNo class within class” please
Introduction to PHP
●
Today’s web user’s expect exciting pages that are
updated frequently and provide a customized
experience for them.
●
Web sites are more like communities to which
they will return time and again.
Cont.
At the same time, website administrators want sites that are
easier to update , maintain and understanding , that is the only
real way to keep up with visitor’s expectations.
For these reasons and more, PHP and MYSQL have become
the fact standards for creating dynamic, database-driven
websites.
PHP History
●
1994: Created by Rasmis Lesdorf, software engineer (part
of Apache Team)
●
1995: Called Personal Home Page Tool, then released as
version 2 with name PHP/FI (Form Interpreter, to analyze
SQL queries)
●
Half 1997: used by 50,000 web sites
●
October 1998: used by 100,000 websites
●
End 1999: used by 1,000,000 websites
Alternatives to PHP
●
Practical extraction and Report Language (Perl)
●
Active Server Pages (ASP)
●
Java server pages (JSP)
●
Ruby
(Good) Topics about PHP
●
Open-source
●
Easy to use ( C-like and Perl-like syntax)
●
Stable and fast
●
Multiplatform
●
Many databases support
●
Many common built-in libraries
●
Pre-installed in Linux distributions
MySQL
●
MySQL is the world’s most popular open-
source database.
●
MySQL is a database management system
(DBMS) for relational databases, therefor
MySQL is an RDBMS.
Cont.’
●
A database , in the simplest terms is a
collection of interrelated data, be it text,
numbers or binary files that are stored and
kept organized by the DBMS.
●
MySQL is an open-source application like
PHP, meaning that it is free to use or even
modify.
Cont.’
●
MySQL software consist of several pieces,
including the MySQL server (mysqld which runs
& manges the databases ), the MySQL
client( mysql, which gives you an interface to the
serves ) and numerous utilities for
maintenance and other purposes.
●
MySQL can handle databases as large as
60,000 tables with more than five billions
rows.
What you’ll need
1. Web server applications ( e.g. apacha, Abyes or IIS)
2. PHP
3. MySQL
4. A web browser ( e.g. Microsoft’s Internet Explorer and
Mozilla’s Firefox )
5. A text editor, PHP-capable such as Adob’s
Dreamweaver qualifies or IDE
6. An FTP application, if using a remote server.
How PHP generates
HTML/JS Web pages
1: Client from browser send HTTP request (with POST/GET
variables)
2: Apache recognizes that a PHP script is requested and sends the
request to PHP module
3: PHP interpreter executes PHP script, collects script output and
sends it back
4: Apache replies to client using the PHP script output as HTML
output
2
Client
Browser
1 PHP
module3
4
Apache
Hello World! (web oriented)
<html>
<head>
<title>My personal Hello World! PHP script</title>
</head>
<body>
<?
echo “Hello World!”;
?>
</html>
PHP tag, allow to insert PHP
code. Interpretation by PHP
module will substitute the code
with code output
Sending data to the web bowser
●
To create dynamic websites with PHP, you must know
how to send data to the web browser.
●
PHP has a number of built-in functions for this purpose,
the most common being echo( ) and print ()
●
e.g: echo ‘ Hello world ‘ ;
●
All PHP statement must end with semicolon.
●
PHP is case-insensitive when it comes to function names,
so Echo ( ), echo ( ), eCHo ( ) will all work.
Writing Comments
●
PHP supports three comments types.
●
The first uses the Pound or number symbol ( # ).
●
e.g. # this is a comment
●
The second uses two slashes.
●
e.g. // this is also comment
●
Both of these cause PHP to ignore everything that
follows untill the end of line, thus these two
comments are for single lines only.
Cont.
A third style allows comments to run over multiple lines.
e.g. /* this is a larger comments that spans too lines of comments. */
●
Variables are containers used to temporarily store
values, these values can be numbers , text or
much more complex data.
●
PHP has eight types of variables.
●
These include four scalar (single –valued) types
Bolean ( true or false), integer, floating point
(decimals ) and strings (characters ); two
nonscalar ( multi-valued) array and object, plus
resource (DB) and null (no value).
What are variables?
Rules of variable
●
Regardless of what type you are creating, all
variables in PHP follow certain syntactical rules.
1. A variable’s name also called its identifier must
start with a dollar sign ($) . E.g. $name
2. The variable’s name can contain a combination of
strings, numbers and the underscore. E.g. $My-
report1.
3. The first character after dollar sign must be a letter
or an underscore ( not be in a number).
Cont.
●
4. Variable names in PHP are case –sensitive.
●
This is very important rule. It means that $name
and $Name are entirely different variables.
●
Note: before getting into a script, there are two
more things you should know, first , variables can
be assigned values using the equal sing ( = ) also
called the assignment operator.
●
Second , variables can be printed with out
quotation mark. E.g.: print $some_var;
Cont.
●
# variables must be printed within double
quotation mark.
●
e.g. : print “ Hello, $name “;
●
# You can not print variables within single
quotation marks.
●
e.g. : print ‘ Hello, $name ‘ ; // won’t work.
END

More Related Content

Similar to Php1 (20)

Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
PHP MySQL Workshop - facehook
PHP MySQL Workshop - facehookPHP MySQL Workshop - facehook
PHP MySQL Workshop - facehook
 
Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1
 
INTRODUCTION TO PHP.ppt
INTRODUCTION TO PHP.pptINTRODUCTION TO PHP.ppt
INTRODUCTION TO PHP.ppt
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Php introduction
Php introductionPhp introduction
Php introduction
 
Introduction to-php
Introduction to-phpIntroduction to-php
Introduction to-php
 
chapter Two Server-side Script lang.pptx
chapter  Two Server-side Script lang.pptxchapter  Two Server-side Script lang.pptx
chapter Two Server-side Script lang.pptx
 
PHP Basics Ebook
PHP Basics EbookPHP Basics Ebook
PHP Basics Ebook
 
phptutorial
phptutorialphptutorial
phptutorial
 
phptutorial
phptutorialphptutorial
phptutorial
 
Php intro
Php introPhp intro
Php intro
 
Php intro
Php introPhp intro
Php intro
 
Php intro
Php introPhp intro
Php intro
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Php unit i
Php unit iPhp unit i
Php unit i
 
Php Interview Questions
Php Interview QuestionsPhp Interview Questions
Php Interview Questions
 
Php unit i
Php unit i Php unit i
Php unit i
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Lecture1 introduction by okello erick
Lecture1 introduction by okello erickLecture1 introduction by okello erick
Lecture1 introduction by okello erick
 

Recently uploaded

定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一3sw2qly1
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
Call Girls in East Of Kailash 9711199171 Delhi Enjoy Call Girls With Our Escorts
Call Girls in East Of Kailash 9711199171 Delhi Enjoy Call Girls With Our EscortsCall Girls in East Of Kailash 9711199171 Delhi Enjoy Call Girls With Our Escorts
Call Girls in East Of Kailash 9711199171 Delhi Enjoy Call Girls With Our Escortsindian call girls near you
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一Fs
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Roomdivyansh0kumar0
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607dollysharma2066
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663Call Girls Mumbai
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024APNIC
 
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on DeliveryCall Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Deliverybabeytanya
 
Russian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service ThaneRussian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service ThaneCall girls in Ahmedabad High profile
 

Recently uploaded (20)

定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
Call Girls in East Of Kailash 9711199171 Delhi Enjoy Call Girls With Our Escorts
Call Girls in East Of Kailash 9711199171 Delhi Enjoy Call Girls With Our EscortsCall Girls in East Of Kailash 9711199171 Delhi Enjoy Call Girls With Our Escorts
Call Girls in East Of Kailash 9711199171 Delhi Enjoy Call Girls With Our Escorts
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girls
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on DeliveryCall Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
 
Russian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service ThaneRussian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
 

Php1

  • 1. Introduction Ayub hussein abdulle Msc in CSE University of somalia (UNISO) PHP & MySQL
  • 2.  IntroductionIntroduction  Text Book/Reference MaterialsText Book/Reference Materials  ContentsContents  AssessmentAssessment  QuizQuiz 10%10%  Ass/PRAss/PR 20%20%  Mid Quarter ExamMid Quarter Exam 30%30%  Final ExamFinal Exam 40%40%  Rules of the classRules of the class  Mobiles on “Silent” please MSCMobiles on “Silent” please MSC – CSE, Lecturer: Engr. Ayub– CSE, Lecturer: Engr. Ayub HusseinHussein  ““No class within class” pleaseNo class within class” please
  • 3. Introduction to PHP ● Today’s web user’s expect exciting pages that are updated frequently and provide a customized experience for them. ● Web sites are more like communities to which they will return time and again.
  • 4. Cont. At the same time, website administrators want sites that are easier to update , maintain and understanding , that is the only real way to keep up with visitor’s expectations. For these reasons and more, PHP and MYSQL have become the fact standards for creating dynamic, database-driven websites.
  • 5. PHP History ● 1994: Created by Rasmis Lesdorf, software engineer (part of Apache Team) ● 1995: Called Personal Home Page Tool, then released as version 2 with name PHP/FI (Form Interpreter, to analyze SQL queries) ● Half 1997: used by 50,000 web sites ● October 1998: used by 100,000 websites ● End 1999: used by 1,000,000 websites
  • 6. Alternatives to PHP ● Practical extraction and Report Language (Perl) ● Active Server Pages (ASP) ● Java server pages (JSP) ● Ruby
  • 7. (Good) Topics about PHP ● Open-source ● Easy to use ( C-like and Perl-like syntax) ● Stable and fast ● Multiplatform ● Many databases support ● Many common built-in libraries ● Pre-installed in Linux distributions
  • 8. MySQL ● MySQL is the world’s most popular open- source database. ● MySQL is a database management system (DBMS) for relational databases, therefor MySQL is an RDBMS.
  • 9. Cont.’ ● A database , in the simplest terms is a collection of interrelated data, be it text, numbers or binary files that are stored and kept organized by the DBMS. ● MySQL is an open-source application like PHP, meaning that it is free to use or even modify.
  • 10. Cont.’ ● MySQL software consist of several pieces, including the MySQL server (mysqld which runs & manges the databases ), the MySQL client( mysql, which gives you an interface to the serves ) and numerous utilities for maintenance and other purposes. ● MySQL can handle databases as large as 60,000 tables with more than five billions rows.
  • 11. What you’ll need 1. Web server applications ( e.g. apacha, Abyes or IIS) 2. PHP 3. MySQL 4. A web browser ( e.g. Microsoft’s Internet Explorer and Mozilla’s Firefox ) 5. A text editor, PHP-capable such as Adob’s Dreamweaver qualifies or IDE 6. An FTP application, if using a remote server.
  • 12. How PHP generates HTML/JS Web pages 1: Client from browser send HTTP request (with POST/GET variables) 2: Apache recognizes that a PHP script is requested and sends the request to PHP module 3: PHP interpreter executes PHP script, collects script output and sends it back 4: Apache replies to client using the PHP script output as HTML output 2 Client Browser 1 PHP module3 4 Apache
  • 13. Hello World! (web oriented) <html> <head> <title>My personal Hello World! PHP script</title> </head> <body> <? echo “Hello World!”; ?> </html> PHP tag, allow to insert PHP code. Interpretation by PHP module will substitute the code with code output
  • 14. Sending data to the web bowser ● To create dynamic websites with PHP, you must know how to send data to the web browser. ● PHP has a number of built-in functions for this purpose, the most common being echo( ) and print () ● e.g: echo ‘ Hello world ‘ ; ● All PHP statement must end with semicolon. ● PHP is case-insensitive when it comes to function names, so Echo ( ), echo ( ), eCHo ( ) will all work.
  • 15. Writing Comments ● PHP supports three comments types. ● The first uses the Pound or number symbol ( # ). ● e.g. # this is a comment ● The second uses two slashes. ● e.g. // this is also comment ● Both of these cause PHP to ignore everything that follows untill the end of line, thus these two comments are for single lines only.
  • 16. Cont. A third style allows comments to run over multiple lines. e.g. /* this is a larger comments that spans too lines of comments. */
  • 17. ● Variables are containers used to temporarily store values, these values can be numbers , text or much more complex data. ● PHP has eight types of variables. ● These include four scalar (single –valued) types Bolean ( true or false), integer, floating point (decimals ) and strings (characters ); two nonscalar ( multi-valued) array and object, plus resource (DB) and null (no value). What are variables?
  • 18. Rules of variable ● Regardless of what type you are creating, all variables in PHP follow certain syntactical rules. 1. A variable’s name also called its identifier must start with a dollar sign ($) . E.g. $name 2. The variable’s name can contain a combination of strings, numbers and the underscore. E.g. $My- report1. 3. The first character after dollar sign must be a letter or an underscore ( not be in a number).
  • 19. Cont. ● 4. Variable names in PHP are case –sensitive. ● This is very important rule. It means that $name and $Name are entirely different variables. ● Note: before getting into a script, there are two more things you should know, first , variables can be assigned values using the equal sing ( = ) also called the assignment operator. ● Second , variables can be printed with out quotation mark. E.g.: print $some_var;
  • 20. Cont. ● # variables must be printed within double quotation mark. ● e.g. : print “ Hello, $name “; ● # You can not print variables within single quotation marks. ● e.g. : print ‘ Hello, $name ‘ ; // won’t work.
  • 21. END