SlideShare a Scribd company logo
1 of 5
PHP Made Easy by Dr. Perl1




What is PHP?
PHP (recursive acronym for quot;PHP: Hypertext Preprocessorquot;) is a widely-used Open Source general-purpose scripting
language that is especially suited for Web development and can be embedded into HTML.

Simple answer, but what does that mean? An example:

Example: An introductory example

 <html>
    <head>
         <title>Example</title>
    </head>
    <body>
         <?php
         echo quot;Hi, I'm a PHP script!quot;;
         ?>
    </body>
 </html>

The above written quote and example is from PHP's official manual. Let me explain and introduce you with PHP in
some more detail.

Most of us spend a few hours on internet to check/send emails, view/post something to a discussion board (like this
one), to search for some solutions using search engines, do some orkut or facebook. But a few of us will ever realize
that what has made these sites so powerful, intelligent and self-maintaining?

Very simple answer to this question is: Web Application Development Technologies.

Don't get afraid of this heavy words term - it's all about the techniques and how you use 'em. Another simple answer
would be the, PHP, ASP (Active Server Pages), JSP(Java Server Pages), CFM (Cold Fusion Markup Language) or PERL
(Practical Extraction and Reporting Language). These are most renowned web scripting languages and are widely
used to develop (or simply program) a website to register users, allow them to post topics, view topics, chat with
friends and etc etc.

In this series (PHP Made Easy by Dr. Perl) I will introduce you to the PHP, what it can do and how you can benefit
from PHP?

You can use PHP to:

    •    Print current date and time on your website.

    •    Print greetings to your visitors based on time, like Good Morning, Good Noon and etc.

    •    Ask comments about your article.

    •    Offer subscription to your weekly news letter.
             drperl@hotmail.com
PHP Made Easy by Dr. Perl2



    •    Register visitors to enjoy member services.

    •    Enable your website to accept online payments, via Credit Cards, PayPal and etc.

    •    Keep track of daily visits on your website.

    •    Collect statistical data from daily visits, to find out that how long a user stayed on your website and which
         pages were browsed mostly and likewise.

    •    Administer your website remotely, so that you won't need to create page locally and then to upload - called
         CMS (Content Management System)

    •    and a very long list to go...

First things first - I mean before you get more excited, let's prepare an environment where you can practice PHP and
can create your website.

All you have to do is to download Apache, MySQL and PHP - just install and configure - and you are good to go!!!
Sounds crazy? Don't worry :) this isn't a big deal, just a matter of few clicks. Simply download XAMPP from
http://www.apachefriends.org/download.php?xampp-win32-1.7.0-installer.exe. This is a windows based installer
which will install and configure everything for you. During installation it will ask you a few questions, just proceed
with clicks - But take care of only one thing that you need to select option for Apache and MySQL to run as a service -
when asked.

Once you have installed xampp, look for the quot;htdocsquot; folder under the installation of your xampp location. This is the
folder where you will place all of your PHP files. The better idea is to create separate folders for each project (or
website).

 Quick Note:

 Apache - Web Server
 MySQL - Database Server

Say Hello to World
The most popular and common first-code, a developer/programmer tries is quot;A Hello Worldquot; example. Fire up your
note pad and write following code in a new file.

 <?php
 echo quot;Hello Worldquot;;
 ?>

Save the file as quot;helloWorld.phpquot; under quot;htdocsquot; folder. Now fire up your favorite web browser (Firefox, IE, Opera,
Safari or etc) and type in the following address (URL) in browser's address bar.

http://localhost/helloWorld.php]http://localhost/helloWorld.php

This should load your helloWorld.php and should say:

             drperl@hotmail.com
PHP Made Easy by Dr. Perl3



Hello World

in the browser's web page display area. Waowww... we've got another developer... ;D

Now let's have a closer look into our first PHP code (usually called script).

 <?php
 ...
 ?>

The <? and ?> are the opening and closing markers (tags) of a PHP script, respectively. As I have mentioned earlier in
this article that PHP can be embedded in HTML, so the web server has to understand that which part of the web page
will be parsed (handled) by PHP itself. Usually, when we save a file as .php extension, web server automatically hands
over the calls to PHP compiler (because web server is configured for handling php files also - don't bother with it, just
carry on).

Anyway, the PHP code is enclosed between <? and ?> php tags. Alternatively you can write these tags as following
also:

 <?php
 ...
 ?>

or

 <?php
 ...
 ?>

Now, move on,

 <?php
 echo quot;Hello Worldquot;;
 ?>

quot;echoquot; is a PHP's language construct, which is also known as a function, but isn't a true function. However, echo
outputs one or more strings (data, numeric, alphabets or alphanumeric). Whatever you provide to echo, in double
quotes (quot;) or single quotes (') will be printed-out.

Add some more stuff
 <?php
 /*
 My first program in PHP.
 Written by Dr. Perl
 */


              drperl@hotmail.com
PHP Made Easy by Dr. Perl4



 // Print the message.
 echo quot;Hello Worldquot;;
 ?>

As you see /*, */ and // in above code with a few english sentences - are the quot;commentsquot; or quot;remarksquot;. A comment
is what you insert in your source code to remember or to explain something about a certain part of code, about a
chunk of code or about a single line. These are helpful for you. You can use comments to take notes, that what
exactly the code does or what has been changed since last version of this code. However, these comments are
ignored by PHP compiler and do not affect the code.

Do some variables
 <?php
 /*
 A simple calculator.
 Adds two values and prints the result.
 */

 // Define some values
 $a = 10;
 $b = 10;

 // Addition
 $c = $a + $b;

 // Print out the result
 echo $c;
 ?>

$ symbol is used to define a variable. A variable name can be anything meaningful, should start with $ sign. A variable
name itself should start with alphabet and can have numerics after that. The above code defines 3 variables, $a, $b
and $c. $a and $b contains values while $c contains the result of $a + $b (after addition). quot;echoquot; simply prints out the
$c (whatever it contains).

Alternatively, you can write above code as:

 <?php
 /*
 A simple calculator.
 Adds two values and prints the result.
 */

 // Define some values
 $a = 10;
 $b = 10;

             drperl@hotmail.com
PHP Made Easy by Dr. Perl5




 // Print out the result
 echo ($a + $b);
 ?>

Notice the 3rd variable $c is missing, because I have directly written the calculation part in the echo statement. I have
put parenthesis around the $a + $b to make it sure that it should be calculated first then should be printed out (ah!
the maths - I don't like really!!). Try it without parenthesis and figure out the results.

Summing Up
So far you have got a basic introduction to PHP, Setting up quick environment and writing basic script. Do some
practices, below is a list of few useful links which you should keep in your favorites list and may need anytime for
quick references.

Resources
www.zend.com - The PHP Company, find manual, tutorials and etc.
www.php.net - Home of PHP, find manual, and php downloads
www.mysql.com - MySQL official website
www.welive.ws - Get free space for your own website, PHP supported
www.esearchbook.com - Download free books, videos, tutorials and Share your own
www.freebookforeveryone.com - Online readable free books on PHP, PERL, Java, MySQL and etc.



Written by Dr. Perl
drperl@hotmail.com




             drperl@hotmail.com

More Related Content

What's hot

What's hot (9)

php_tizag_tutorial
php_tizag_tutorialphp_tizag_tutorial
php_tizag_tutorial
 
Basic php
Basic phpBasic php
Basic php
 
Babitha5.php
Babitha5.phpBabitha5.php
Babitha5.php
 
Php
PhpPhp
Php
 
Dynamic Web Pages Ch 1 V1.0
Dynamic Web Pages Ch 1 V1.0Dynamic Web Pages Ch 1 V1.0
Dynamic Web Pages Ch 1 V1.0
 
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
 
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
 
Software Design
Software DesignSoftware Design
Software Design
 
Php notes 01
Php notes 01Php notes 01
Php notes 01
 

Viewers also liked

Fiscal 2005 10-K Annual Report
Fiscal 2005 10-K Annual Report Fiscal 2005 10-K Annual Report
Fiscal 2005 10-K Annual Report finance2
 
2003 Merrill Lynch Global Healthcare Conference
	 2003 Merrill Lynch Global Healthcare Conference	 2003 Merrill Lynch Global Healthcare Conference
2003 Merrill Lynch Global Healthcare Conferencefinance2
 
Baird Conference Presentation
	 Baird Conference Presentation	 Baird Conference Presentation
Baird Conference Presentationfinance2
 
HIMSS Investor Briefing
HIMSS Investor BriefingHIMSS Investor Briefing
HIMSS Investor Briefingfinance2
 
Lehman Brothers 2003 Global Heathcare Conference
	 Lehman Brothers 2003 Global Heathcare Conference	 Lehman Brothers 2003 Global Heathcare Conference
Lehman Brothers 2003 Global Heathcare Conferencefinance2
 
Anatomía y Terminología basica de un BLOG
Anatomía y Terminología basica de un BLOGAnatomía y Terminología basica de un BLOG
Anatomía y Terminología basica de un BLOGPoli Suñer
 

Viewers also liked (7)

Fiscal 2005 10-K Annual Report
Fiscal 2005 10-K Annual Report Fiscal 2005 10-K Annual Report
Fiscal 2005 10-K Annual Report
 
2003 Merrill Lynch Global Healthcare Conference
	 2003 Merrill Lynch Global Healthcare Conference	 2003 Merrill Lynch Global Healthcare Conference
2003 Merrill Lynch Global Healthcare Conference
 
Paula
PaulaPaula
Paula
 
Baird Conference Presentation
	 Baird Conference Presentation	 Baird Conference Presentation
Baird Conference Presentation
 
HIMSS Investor Briefing
HIMSS Investor BriefingHIMSS Investor Briefing
HIMSS Investor Briefing
 
Lehman Brothers 2003 Global Heathcare Conference
	 Lehman Brothers 2003 Global Heathcare Conference	 Lehman Brothers 2003 Global Heathcare Conference
Lehman Brothers 2003 Global Heathcare Conference
 
Anatomía y Terminología basica de un BLOG
Anatomía y Terminología basica de un BLOGAnatomía y Terminología basica de un BLOG
Anatomía y Terminología basica de un BLOG
 

Similar to Article 01 What Is Php

Similar to Article 01 What Is Php (20)

Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
Php
PhpPhp
Php
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power point
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power point
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power point
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power point
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power point
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power point
 
PHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERSPHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERS
 
PHP.docx
PHP.docxPHP.docx
PHP.docx
 
Php tizag tutorial
Php tizag tutorialPhp tizag tutorial
Php tizag tutorial
 
PHP learning
PHP learningPHP learning
PHP learning
 
php_tizag_tutorial
php_tizag_tutorialphp_tizag_tutorial
php_tizag_tutorial
 
Php tizag tutorial
Php tizag tutorial Php tizag tutorial
Php tizag tutorial
 
Php tizag tutorial
Php tizag tutorialPhp tizag tutorial
Php tizag tutorial
 
php basics
php basicsphp basics
php basics
 

Recently uploaded

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 

Recently uploaded (20)

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 

Article 01 What Is Php

  • 1. PHP Made Easy by Dr. Perl1 What is PHP? PHP (recursive acronym for quot;PHP: Hypertext Preprocessorquot;) is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. Simple answer, but what does that mean? An example: Example: An introductory example <html> <head> <title>Example</title> </head> <body> <?php echo quot;Hi, I'm a PHP script!quot;; ?> </body> </html> The above written quote and example is from PHP's official manual. Let me explain and introduce you with PHP in some more detail. Most of us spend a few hours on internet to check/send emails, view/post something to a discussion board (like this one), to search for some solutions using search engines, do some orkut or facebook. But a few of us will ever realize that what has made these sites so powerful, intelligent and self-maintaining? Very simple answer to this question is: Web Application Development Technologies. Don't get afraid of this heavy words term - it's all about the techniques and how you use 'em. Another simple answer would be the, PHP, ASP (Active Server Pages), JSP(Java Server Pages), CFM (Cold Fusion Markup Language) or PERL (Practical Extraction and Reporting Language). These are most renowned web scripting languages and are widely used to develop (or simply program) a website to register users, allow them to post topics, view topics, chat with friends and etc etc. In this series (PHP Made Easy by Dr. Perl) I will introduce you to the PHP, what it can do and how you can benefit from PHP? You can use PHP to: • Print current date and time on your website. • Print greetings to your visitors based on time, like Good Morning, Good Noon and etc. • Ask comments about your article. • Offer subscription to your weekly news letter. drperl@hotmail.com
  • 2. PHP Made Easy by Dr. Perl2 • Register visitors to enjoy member services. • Enable your website to accept online payments, via Credit Cards, PayPal and etc. • Keep track of daily visits on your website. • Collect statistical data from daily visits, to find out that how long a user stayed on your website and which pages were browsed mostly and likewise. • Administer your website remotely, so that you won't need to create page locally and then to upload - called CMS (Content Management System) • and a very long list to go... First things first - I mean before you get more excited, let's prepare an environment where you can practice PHP and can create your website. All you have to do is to download Apache, MySQL and PHP - just install and configure - and you are good to go!!! Sounds crazy? Don't worry :) this isn't a big deal, just a matter of few clicks. Simply download XAMPP from http://www.apachefriends.org/download.php?xampp-win32-1.7.0-installer.exe. This is a windows based installer which will install and configure everything for you. During installation it will ask you a few questions, just proceed with clicks - But take care of only one thing that you need to select option for Apache and MySQL to run as a service - when asked. Once you have installed xampp, look for the quot;htdocsquot; folder under the installation of your xampp location. This is the folder where you will place all of your PHP files. The better idea is to create separate folders for each project (or website). Quick Note: Apache - Web Server MySQL - Database Server Say Hello to World The most popular and common first-code, a developer/programmer tries is quot;A Hello Worldquot; example. Fire up your note pad and write following code in a new file. <?php echo quot;Hello Worldquot;; ?> Save the file as quot;helloWorld.phpquot; under quot;htdocsquot; folder. Now fire up your favorite web browser (Firefox, IE, Opera, Safari or etc) and type in the following address (URL) in browser's address bar. http://localhost/helloWorld.php]http://localhost/helloWorld.php This should load your helloWorld.php and should say: drperl@hotmail.com
  • 3. PHP Made Easy by Dr. Perl3 Hello World in the browser's web page display area. Waowww... we've got another developer... ;D Now let's have a closer look into our first PHP code (usually called script). <?php ... ?> The <? and ?> are the opening and closing markers (tags) of a PHP script, respectively. As I have mentioned earlier in this article that PHP can be embedded in HTML, so the web server has to understand that which part of the web page will be parsed (handled) by PHP itself. Usually, when we save a file as .php extension, web server automatically hands over the calls to PHP compiler (because web server is configured for handling php files also - don't bother with it, just carry on). Anyway, the PHP code is enclosed between <? and ?> php tags. Alternatively you can write these tags as following also: <?php ... ?> or <?php ... ?> Now, move on, <?php echo quot;Hello Worldquot;; ?> quot;echoquot; is a PHP's language construct, which is also known as a function, but isn't a true function. However, echo outputs one or more strings (data, numeric, alphabets or alphanumeric). Whatever you provide to echo, in double quotes (quot;) or single quotes (') will be printed-out. Add some more stuff <?php /* My first program in PHP. Written by Dr. Perl */ drperl@hotmail.com
  • 4. PHP Made Easy by Dr. Perl4 // Print the message. echo quot;Hello Worldquot;; ?> As you see /*, */ and // in above code with a few english sentences - are the quot;commentsquot; or quot;remarksquot;. A comment is what you insert in your source code to remember or to explain something about a certain part of code, about a chunk of code or about a single line. These are helpful for you. You can use comments to take notes, that what exactly the code does or what has been changed since last version of this code. However, these comments are ignored by PHP compiler and do not affect the code. Do some variables <?php /* A simple calculator. Adds two values and prints the result. */ // Define some values $a = 10; $b = 10; // Addition $c = $a + $b; // Print out the result echo $c; ?> $ symbol is used to define a variable. A variable name can be anything meaningful, should start with $ sign. A variable name itself should start with alphabet and can have numerics after that. The above code defines 3 variables, $a, $b and $c. $a and $b contains values while $c contains the result of $a + $b (after addition). quot;echoquot; simply prints out the $c (whatever it contains). Alternatively, you can write above code as: <?php /* A simple calculator. Adds two values and prints the result. */ // Define some values $a = 10; $b = 10; drperl@hotmail.com
  • 5. PHP Made Easy by Dr. Perl5 // Print out the result echo ($a + $b); ?> Notice the 3rd variable $c is missing, because I have directly written the calculation part in the echo statement. I have put parenthesis around the $a + $b to make it sure that it should be calculated first then should be printed out (ah! the maths - I don't like really!!). Try it without parenthesis and figure out the results. Summing Up So far you have got a basic introduction to PHP, Setting up quick environment and writing basic script. Do some practices, below is a list of few useful links which you should keep in your favorites list and may need anytime for quick references. Resources www.zend.com - The PHP Company, find manual, tutorials and etc. www.php.net - Home of PHP, find manual, and php downloads www.mysql.com - MySQL official website www.welive.ws - Get free space for your own website, PHP supported www.esearchbook.com - Download free books, videos, tutorials and Share your own www.freebookforeveryone.com - Online readable free books on PHP, PERL, Java, MySQL and etc. Written by Dr. Perl drperl@hotmail.com drperl@hotmail.com