SlideShare a Scribd company logo
Developing WebDeveloping Web
Applications with PHPApplications with PHP
RAD for the World
Wide Web
Jeff Jirsa
jjirsa@xnet.com
AgendaAgenda
– Introduction
– PHP Language Basics
– Built-in Functions
– PHP on Linux and Windows
– Tricks and Tips
– PHP 5
– Examples
– Questions?
IntroductionIntroduction
• What is PHP?
– PHP stands for "PHP Hypertext
Preprocessor”
– An embedded scripting language for HTML
like ASP or JSP
– A language that combines elements of
Perl, C, and Java
IntroductionIntroduction
• History of PHP
– Created by Rasmus Lerdorf in 1995 for
tracking access to his resume
– Originally a set of Perl scripts known as the
“Personal Home Page” tools
– Rewritten in C with database functionality
– Added a forms interpreter and released as
PHP/FI: includes Perl-like variables, and
HTML embedded syntax
IntroductionIntroduction
• History of PHP (cont.)
– Rewritten again in and released as version
2.0 in November of 1997
– Estimated user base in 1997 is several
thousand users and 50,000 web sites
served
– Rewritten again in late 1997 by Andi
Gutmans and Zeev Suraski
– More functionality added, database
support, protocols and APIs
IntroductionIntroduction
• History of PHP (cont.)
– User base in 1998 estimated 10,000 users
and 100,000 web sites installed
– Version 3.0 was released in June 1998 as
PHP
– Estimated user base in tens of thousands
and hundreds of thousands of web sites
served
IntroductionIntroduction
• History of PHP (cont.)
– Rewritten again in 1997 by Andi Gutmans
and Zeev Suraski
– More functionality added (OOP features),
database support, protocols and APIs
– PHP 3.0 is released in June 1998 with
some OO capability
– The core is rewritten in 1998 for improved
performance of complex applications
IntroductionIntroduction
• History of PHP (cont.)
– The core is rewritten in 1998 by Zeev and
Andi and dubbed the “Zend Engine”
– The engine is introduced in mid 1999 and
is released with version 4.0 in May of 2000
– The estimated user base is hundreds of
thousands of developers and several
million of web sites served
IntroductionIntroduction
• History of PHP (cont.)
– Version 5.0 will include version 2.0 of the
Zend Engine
• New object model is more powerful and
intuitive
• Objects will no longer be passed by value; they
now will be passed by reference
• Increases performance and makes OOP more
attractive
IntroductionIntroduction
• Netcraft Statistics
– 11,869,645 Domains, 1,316,288 IP Addresses
IntroductionIntroduction
• Performance*
– Zdnet Statistics
• PHP pumped out about 47 pages/second
• Microsoft ASP pumped out about 43
pages/second
• Allaire ColdFusion pumped out about 29
pages/second
• Sun Java JSP pumped out about 13
pages/second
* From PHP HOWTO, July 2001
PHP Language BasicsPHP Language Basics
• The Script Tags
– All PHP code is contained in one of several
script tags:
• <?
// Some code
?>
• <?php
// Some code here
?>
PHP Language BasicsPHP Language Basics
• The Script Tags (cont.)
• <script language=“PHP">
// Some code here
</script>
– ASP-style tags
• Introduced in 3.0; may be removed in the future
• <%
// Some code here
%>
PHP Language BasicsPHP Language Basics
• The Script Tags (cont.)
– “Echo” Tags
– <table>
<tr>
<td>Name:</td><td><?= $name ?></td>
</tr>
<tr>
<td>Address:</td><td><?= $address ?></td>
</tr>
</table>
PHP Language BasicsPHP Language Basics
• Hello World!: An Example
– Like Perl, there is more than one way to do
it
• <?php echo “Hello World!”; ?>
• <?php
$greeting = “Hello World!”
printf(“%s”, $greeting);
php?>
PHP Language BasicsPHP Language Basics
• Hello World!: An Example (cont.)
• <script language=“PHP”>
$hello = “Hello”;
$world = “World!”;
print $hello . $world
</script>
PHP Language BasicsPHP Language Basics
• Constants, Data Types and
Variables
– Constants define a string or numeric value
– Constants do not begin with a dollar sign
– Examples:
• define(“COMPANY”, “Acme Enterprises”);
• define(“YELLOW”, “#FFFF00”);
• define(“PI”, 3.14);
• define(“NL”, “<br>n”);
PHP Language BasicsPHP Language Basics
• Constants, Data Types and
Variables
– Using a constant
• print(“Company name: “ . COMPANY . NL);
PHP Language BasicsPHP Language Basics
• Constants, Data Types and
Variables
– Data types
• Integers, doubles and strings
– isValid = true; // Boolean
– 25 // Integer
– 3.14 // Double
– ‘Four’ // String
– “Total value” // Another string
PHP Language BasicsPHP Language Basics
• Constants, Data Types and
Variables
– Data types
• Strings and type conversion
– $street = 123;
– $street = $street . “ Main Street”;
– $city = ‘Naperville’;
$state = ‘IL’;
– $address = $street;
– $address = $address . NL . “$city, $state”;
– $number = $address + 1; // $number equals
124
PHP Language BasicsPHP Language Basics
• Constants, Data Types and
Variables
– Data types
• Arrays
– Perl-like syntax
• $arr = array("foo" => "bar", 12 => true);
– same as
• $arr[“foo”] = “bar”;
• $arr[12] = true;
PHP Language BasicsPHP Language Basics
• Constants, Data Types and
Variables
• Arrays (cont.)
– <?php
$arr = array("somearray" => array(6 => 5, 13 => 9,
"a" => 42));
echo $arr["somearray"][6]; // 5
echo $arr["somearray"][13]; // 9
echo $arr["somearray"]["a"]; // 42
?>
PHP Language BasicsPHP Language Basics
• Constants, Data Types and
Variables
– Objects
– Currently not much more advanced than than
associative arrays Using constants
– Before version 5.0, objects are passed by value
• Slow
• Functions can not easily change object variables
PHP Language BasicsPHP Language Basics
• Constants, Data Types and
Variables
– Operators
– Contains all of the operators like in C and Perl (even
the ternary)
– Statements
– if, if/elseif
– Switch/case
– for, while, and do/while loops
– Include and require statements for code reuse
Built-in FunctionsBuilt-in Functions
• What comes In the box?
– Array Manipulator Functions
• sort, merge, push, pop, slice, splice, keys,
count
– CCVS: Interface to Red Hat’s credit system
– COM functions: Interface to Windows COM
objects
– Date and Time Functions
• getdate, mkdate, date, gettimeofday, localtime,
strtotime, time
Built-in FunctionsBuilt-in Functions
• What comes In the box?
– Directory Functions
• Platform independent
– Error Handling Functions
• Recover from warnings and errors
– Filesystem Functions
• Access flat files
• Check directory, link, and file status information
• Copy, delete, and rename files
Built-in FunctionsBuilt-in Functions
• What comes In the box?
– IMAP Functions
• Manipulate mail boxes via the IMAP protocol
– LDAP Functions
• Works with most LDAP servers
– Mail Functions
• mail($recipient, $subject, $message)
Built-in FunctionsBuilt-in Functions
• What comes In the box?
– Database Functions
• dba: dbm-style abstraction layer
• dBase
• Frontbase
• Informix
• Ingres II
• Interbase
• mSQL
Built-in FunctionsBuilt-in Functions
• What comes In the box?
– Database Functions (cont.)
• MySQL
• Oracle
• PostgreSQL
• SQL Server
– MING
• Macromedia Flash
– PDF
• Create/manipulate PDF files dynamically
Built-in FunctionsBuilt-in Functions
• What comes In the box?
– POSIX Functions
• Manipulate process information
– Regular Expression Functions
• Uses POSIX regex
– Semaphore and Socket Functions
• Available only on Unix
– Session Management Functions
PHP on Linux andPHP on Linux and
WindowsWindows
• Code Portability
– The obvious: don’t use Unix or Windows
specific functions
– Create a reusable module for file system
differences, for example:
– if( PHP_OS == "Linux" )
{
$ConfigPath = "/var/www/conf";
$DataPath = "/var/www/data";
}
PHP on Linux andPHP on Linux and
WindowsWindows
• Code Portability
– if( ereg("WIN", PHP_OS) )
{
$ApachePath = “C:/Program Files/Apache
Group/Apache”;
$ConfigPath = ”$ApachePath/htdocs/conf";
$DataPath = "$ApachePath/htdocs/data";
}
$ConfigFile = "$ConfigPath/paperwork.conf";
$CountryList = "$DataPath/countries.txt";
$StateAbbrList = "$DataPath/usstateabbrs.txt";
$StateNameList = "$DataPath/usstatenames.txt";
Tricks and TipsTricks and Tips
• Coding
– Prototype your web pages first
• Separate the design of the site from the coding
– Turn repetitive code into functions
• Makes for more maintainable and reusable
code
– Turn grunt code into functions
• Database access, configuration file access
Tricks and TipsTricks and Tips
• Debugging
– Feature: PHP is not a strongly typed
language
• Variables can be created anywhere in your
code
– Undocumented Feature: PHP is not a
strongly typed language
• Typos in variable names will cause stuff to
happen
Tricks and TipsTricks and Tips
• Debugging
– Use scripts to dump form and session
variables
• Write scripts to dump data to discover bad or
missing data
Tricks and TipsTricks and Tips
• Development Tools
– Color coding editors
• vim, Emacs, Visual SlickEdit
– IDEs
• Windows
– Macromedia Dreamweaver
– Allaire Homesite
– Zend’s PHPEdit
• Linux
– ???
PHP 5PHP 5
• Release Date
– ???
• Features
– Complete objects
• Objects with constructors
• Abstract classes
• Private, protected and abstract functions
• Private, protected and constant variables
• Namespaces
• Exception handling with try/catch blocks
ResourcesResources
• PHP Downloads and Online
Documentation
– www.php.net
• Community
– www.phpbuilder.com: articles on PHP, discussion
forums
– www.phpresourceindex.com: over 1,000 PHP scripts
– www.phpvolcano.com: PHP 5 information
• Newsgroups
– comp.lang.php
Questions?Questions?
– Any Questions
• www.php.net
– Community
• www.phpbuilder.com: articles on PHP,
discussion forums
– Newsgroups
• comp.lang.php

More Related Content

Viewers also liked

HTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPCHTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPC
Mayflower GmbH
 
Android studio
Android studioAndroid studio
Android studio
Paresh Mayani
 
Como elaborarplaneargume
Como elaborarplaneargumeComo elaborarplaneargume
Como elaborarplaneargume
JORGE PEREGRINO PEREZ
 
Navegadores Safari y Omega
Navegadores Safari y Omega Navegadores Safari y Omega
Navegadores Safari y Omega
Patricio Gallo
 
sb_573_bill_20150623_amended_asm_v96
sb_573_bill_20150623_amended_asm_v96sb_573_bill_20150623_amended_asm_v96
sb_573_bill_20150623_amended_asm_v96
Janice Sutherland
 
Luis caballero
Luis caballeroLuis caballero
Luis caballero
DGC1296
 
Luis caballero
Luis caballeroLuis caballero
Luis caballero
DGC1296
 
En la vida diez en la escuela cero publicar
En la vida diez en la escuela cero publicarEn la vida diez en la escuela cero publicar
En la vida diez en la escuela cero publicar
ivettsantosdelapuerta
 
Tics- Enrique Chacón
Tics- Enrique ChacónTics- Enrique Chacón
Tics- Enrique Chacón
Enrique1197
 
La comunicación José Pérez
La comunicación José Pérez La comunicación José Pérez
La comunicación José Pérez
José Pérez
 
SaaS- Setting up Software as a Service for your Startup
SaaS- Setting up Software as a Service for your StartupSaaS- Setting up Software as a Service for your Startup
SaaS- Setting up Software as a Service for your Startup
Jasper Frumau
 
Historia de Internet L.J
Historia de Internet L.J Historia de Internet L.J
Historia de Internet L.J
capitansalami65
 
Speciaalonderzoek Denise Heins online versie
Speciaalonderzoek Denise Heins online versieSpeciaalonderzoek Denise Heins online versie
Speciaalonderzoek Denise Heins online versieDenise Heins
 
Pres joaquin matias
Pres joaquin matiasPres joaquin matias
Pres joaquin matias
joacox97
 
Café Vanellope - Vanessa leon
Café Vanellope - Vanessa leonCafé Vanellope - Vanessa leon
Café Vanellope - Vanessa leon
vanessa201012
 

Viewers also liked (16)

HTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPCHTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPC
 
Android studio
Android studioAndroid studio
Android studio
 
Como elaborarplaneargume
Como elaborarplaneargumeComo elaborarplaneargume
Como elaborarplaneargume
 
Navegadores Safari y Omega
Navegadores Safari y Omega Navegadores Safari y Omega
Navegadores Safari y Omega
 
sb_573_bill_20150623_amended_asm_v96
sb_573_bill_20150623_amended_asm_v96sb_573_bill_20150623_amended_asm_v96
sb_573_bill_20150623_amended_asm_v96
 
Luis caballero
Luis caballeroLuis caballero
Luis caballero
 
Luis caballero
Luis caballeroLuis caballero
Luis caballero
 
En la vida diez en la escuela cero publicar
En la vida diez en la escuela cero publicarEn la vida diez en la escuela cero publicar
En la vida diez en la escuela cero publicar
 
Tics- Enrique Chacón
Tics- Enrique ChacónTics- Enrique Chacón
Tics- Enrique Chacón
 
ILM Certificate
ILM CertificateILM Certificate
ILM Certificate
 
La comunicación José Pérez
La comunicación José Pérez La comunicación José Pérez
La comunicación José Pérez
 
SaaS- Setting up Software as a Service for your Startup
SaaS- Setting up Software as a Service for your StartupSaaS- Setting up Software as a Service for your Startup
SaaS- Setting up Software as a Service for your Startup
 
Historia de Internet L.J
Historia de Internet L.J Historia de Internet L.J
Historia de Internet L.J
 
Speciaalonderzoek Denise Heins online versie
Speciaalonderzoek Denise Heins online versieSpeciaalonderzoek Denise Heins online versie
Speciaalonderzoek Denise Heins online versie
 
Pres joaquin matias
Pres joaquin matiasPres joaquin matias
Pres joaquin matias
 
Café Vanellope - Vanessa leon
Café Vanellope - Vanessa leonCafé Vanellope - Vanessa leon
Café Vanellope - Vanessa leon
 

Similar to Php

phpwebdev.ppt
phpwebdev.pptphpwebdev.ppt
phpwebdev.ppt
rawaccess
 
Website designing company_in_delhi_phpwebdevelopment
Website designing company_in_delhi_phpwebdevelopmentWebsite designing company_in_delhi_phpwebdevelopment
Website designing company_in_delhi_phpwebdevelopment
Css Founder
 
Synapse india reviews on php website development
Synapse india reviews on php website developmentSynapse india reviews on php website development
Synapse india reviews on php website development
saritasingh19866
 
Basics PHP
Basics PHPBasics PHP
Phpwebdev
PhpwebdevPhpwebdev
Phpwebdev
Luv'k Verma
 
Phpwebdevelping
PhpwebdevelpingPhpwebdevelping
Phpwebdevelping
mohamed ashraf
 
PHP ITCS 323
PHP ITCS 323PHP ITCS 323
PHP ITCS 323
Sleepy Head
 
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Muhamad Al Imran
 
Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHP
Eric Johnson
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Anjan Banda
 
Php
PhpPhp
Php
PhpPhp
Php
PhpPhp
Php
PhpPhp
test
testtest
IntroductiontoPHP.ppt
IntroductiontoPHP.pptIntroductiontoPHP.ppt
IntroductiontoPHP.ppt
truptitasol
 
ssfsd fsdf ds f
ssfsd fsdf ds fssfsd fsdf ds f
ssfsd fsdf ds f
truptitasol
 
test
testtest
IntroductiontoPHP.ppt
IntroductiontoPHP.pptIntroductiontoPHP.ppt
IntroductiontoPHP.ppt
truptitasol
 
sdfsdfsdf
sdfsdfsdfsdfsdfsdf
sdfsdfsdf
truptitasol
 

Similar to Php (20)

phpwebdev.ppt
phpwebdev.pptphpwebdev.ppt
phpwebdev.ppt
 
Website designing company_in_delhi_phpwebdevelopment
Website designing company_in_delhi_phpwebdevelopmentWebsite designing company_in_delhi_phpwebdevelopment
Website designing company_in_delhi_phpwebdevelopment
 
Synapse india reviews on php website development
Synapse india reviews on php website developmentSynapse india reviews on php website development
Synapse india reviews on php website development
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Phpwebdev
PhpwebdevPhpwebdev
Phpwebdev
 
Phpwebdevelping
PhpwebdevelpingPhpwebdevelping
Phpwebdevelping
 
PHP ITCS 323
PHP ITCS 323PHP ITCS 323
PHP ITCS 323
 
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
 
Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHP
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
test
testtest
test
 
IntroductiontoPHP.ppt
IntroductiontoPHP.pptIntroductiontoPHP.ppt
IntroductiontoPHP.ppt
 
ssfsd fsdf ds f
ssfsd fsdf ds fssfsd fsdf ds f
ssfsd fsdf ds f
 
test
testtest
test
 
IntroductiontoPHP.ppt
IntroductiontoPHP.pptIntroductiontoPHP.ppt
IntroductiontoPHP.ppt
 
sdfsdfsdf
sdfsdfsdfsdfsdfsdf
sdfsdfsdf
 

Recently uploaded

Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 

Recently uploaded (20)

Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 

Php

  • 1. Developing WebDeveloping Web Applications with PHPApplications with PHP RAD for the World Wide Web Jeff Jirsa jjirsa@xnet.com
  • 2. AgendaAgenda – Introduction – PHP Language Basics – Built-in Functions – PHP on Linux and Windows – Tricks and Tips – PHP 5 – Examples – Questions?
  • 3. IntroductionIntroduction • What is PHP? – PHP stands for "PHP Hypertext Preprocessor” – An embedded scripting language for HTML like ASP or JSP – A language that combines elements of Perl, C, and Java
  • 4. IntroductionIntroduction • History of PHP – Created by Rasmus Lerdorf in 1995 for tracking access to his resume – Originally a set of Perl scripts known as the “Personal Home Page” tools – Rewritten in C with database functionality – Added a forms interpreter and released as PHP/FI: includes Perl-like variables, and HTML embedded syntax
  • 5. IntroductionIntroduction • History of PHP (cont.) – Rewritten again in and released as version 2.0 in November of 1997 – Estimated user base in 1997 is several thousand users and 50,000 web sites served – Rewritten again in late 1997 by Andi Gutmans and Zeev Suraski – More functionality added, database support, protocols and APIs
  • 6. IntroductionIntroduction • History of PHP (cont.) – User base in 1998 estimated 10,000 users and 100,000 web sites installed – Version 3.0 was released in June 1998 as PHP – Estimated user base in tens of thousands and hundreds of thousands of web sites served
  • 7. IntroductionIntroduction • History of PHP (cont.) – Rewritten again in 1997 by Andi Gutmans and Zeev Suraski – More functionality added (OOP features), database support, protocols and APIs – PHP 3.0 is released in June 1998 with some OO capability – The core is rewritten in 1998 for improved performance of complex applications
  • 8. IntroductionIntroduction • History of PHP (cont.) – The core is rewritten in 1998 by Zeev and Andi and dubbed the “Zend Engine” – The engine is introduced in mid 1999 and is released with version 4.0 in May of 2000 – The estimated user base is hundreds of thousands of developers and several million of web sites served
  • 9. IntroductionIntroduction • History of PHP (cont.) – Version 5.0 will include version 2.0 of the Zend Engine • New object model is more powerful and intuitive • Objects will no longer be passed by value; they now will be passed by reference • Increases performance and makes OOP more attractive
  • 10. IntroductionIntroduction • Netcraft Statistics – 11,869,645 Domains, 1,316,288 IP Addresses
  • 11. IntroductionIntroduction • Performance* – Zdnet Statistics • PHP pumped out about 47 pages/second • Microsoft ASP pumped out about 43 pages/second • Allaire ColdFusion pumped out about 29 pages/second • Sun Java JSP pumped out about 13 pages/second * From PHP HOWTO, July 2001
  • 12. PHP Language BasicsPHP Language Basics • The Script Tags – All PHP code is contained in one of several script tags: • <? // Some code ?> • <?php // Some code here ?>
  • 13. PHP Language BasicsPHP Language Basics • The Script Tags (cont.) • <script language=“PHP"> // Some code here </script> – ASP-style tags • Introduced in 3.0; may be removed in the future • <% // Some code here %>
  • 14. PHP Language BasicsPHP Language Basics • The Script Tags (cont.) – “Echo” Tags – <table> <tr> <td>Name:</td><td><?= $name ?></td> </tr> <tr> <td>Address:</td><td><?= $address ?></td> </tr> </table>
  • 15. PHP Language BasicsPHP Language Basics • Hello World!: An Example – Like Perl, there is more than one way to do it • <?php echo “Hello World!”; ?> • <?php $greeting = “Hello World!” printf(“%s”, $greeting); php?>
  • 16. PHP Language BasicsPHP Language Basics • Hello World!: An Example (cont.) • <script language=“PHP”> $hello = “Hello”; $world = “World!”; print $hello . $world </script>
  • 17. PHP Language BasicsPHP Language Basics • Constants, Data Types and Variables – Constants define a string or numeric value – Constants do not begin with a dollar sign – Examples: • define(“COMPANY”, “Acme Enterprises”); • define(“YELLOW”, “#FFFF00”); • define(“PI”, 3.14); • define(“NL”, “<br>n”);
  • 18. PHP Language BasicsPHP Language Basics • Constants, Data Types and Variables – Using a constant • print(“Company name: “ . COMPANY . NL);
  • 19. PHP Language BasicsPHP Language Basics • Constants, Data Types and Variables – Data types • Integers, doubles and strings – isValid = true; // Boolean – 25 // Integer – 3.14 // Double – ‘Four’ // String – “Total value” // Another string
  • 20. PHP Language BasicsPHP Language Basics • Constants, Data Types and Variables – Data types • Strings and type conversion – $street = 123; – $street = $street . “ Main Street”; – $city = ‘Naperville’; $state = ‘IL’; – $address = $street; – $address = $address . NL . “$city, $state”; – $number = $address + 1; // $number equals 124
  • 21. PHP Language BasicsPHP Language Basics • Constants, Data Types and Variables – Data types • Arrays – Perl-like syntax • $arr = array("foo" => "bar", 12 => true); – same as • $arr[“foo”] = “bar”; • $arr[12] = true;
  • 22. PHP Language BasicsPHP Language Basics • Constants, Data Types and Variables • Arrays (cont.) – <?php $arr = array("somearray" => array(6 => 5, 13 => 9, "a" => 42)); echo $arr["somearray"][6]; // 5 echo $arr["somearray"][13]; // 9 echo $arr["somearray"]["a"]; // 42 ?>
  • 23. PHP Language BasicsPHP Language Basics • Constants, Data Types and Variables – Objects – Currently not much more advanced than than associative arrays Using constants – Before version 5.0, objects are passed by value • Slow • Functions can not easily change object variables
  • 24. PHP Language BasicsPHP Language Basics • Constants, Data Types and Variables – Operators – Contains all of the operators like in C and Perl (even the ternary) – Statements – if, if/elseif – Switch/case – for, while, and do/while loops – Include and require statements for code reuse
  • 25. Built-in FunctionsBuilt-in Functions • What comes In the box? – Array Manipulator Functions • sort, merge, push, pop, slice, splice, keys, count – CCVS: Interface to Red Hat’s credit system – COM functions: Interface to Windows COM objects – Date and Time Functions • getdate, mkdate, date, gettimeofday, localtime, strtotime, time
  • 26. Built-in FunctionsBuilt-in Functions • What comes In the box? – Directory Functions • Platform independent – Error Handling Functions • Recover from warnings and errors – Filesystem Functions • Access flat files • Check directory, link, and file status information • Copy, delete, and rename files
  • 27. Built-in FunctionsBuilt-in Functions • What comes In the box? – IMAP Functions • Manipulate mail boxes via the IMAP protocol – LDAP Functions • Works with most LDAP servers – Mail Functions • mail($recipient, $subject, $message)
  • 28. Built-in FunctionsBuilt-in Functions • What comes In the box? – Database Functions • dba: dbm-style abstraction layer • dBase • Frontbase • Informix • Ingres II • Interbase • mSQL
  • 29. Built-in FunctionsBuilt-in Functions • What comes In the box? – Database Functions (cont.) • MySQL • Oracle • PostgreSQL • SQL Server – MING • Macromedia Flash – PDF • Create/manipulate PDF files dynamically
  • 30. Built-in FunctionsBuilt-in Functions • What comes In the box? – POSIX Functions • Manipulate process information – Regular Expression Functions • Uses POSIX regex – Semaphore and Socket Functions • Available only on Unix – Session Management Functions
  • 31. PHP on Linux andPHP on Linux and WindowsWindows • Code Portability – The obvious: don’t use Unix or Windows specific functions – Create a reusable module for file system differences, for example: – if( PHP_OS == "Linux" ) { $ConfigPath = "/var/www/conf"; $DataPath = "/var/www/data"; }
  • 32. PHP on Linux andPHP on Linux and WindowsWindows • Code Portability – if( ereg("WIN", PHP_OS) ) { $ApachePath = “C:/Program Files/Apache Group/Apache”; $ConfigPath = ”$ApachePath/htdocs/conf"; $DataPath = "$ApachePath/htdocs/data"; } $ConfigFile = "$ConfigPath/paperwork.conf"; $CountryList = "$DataPath/countries.txt"; $StateAbbrList = "$DataPath/usstateabbrs.txt"; $StateNameList = "$DataPath/usstatenames.txt";
  • 33. Tricks and TipsTricks and Tips • Coding – Prototype your web pages first • Separate the design of the site from the coding – Turn repetitive code into functions • Makes for more maintainable and reusable code – Turn grunt code into functions • Database access, configuration file access
  • 34. Tricks and TipsTricks and Tips • Debugging – Feature: PHP is not a strongly typed language • Variables can be created anywhere in your code – Undocumented Feature: PHP is not a strongly typed language • Typos in variable names will cause stuff to happen
  • 35. Tricks and TipsTricks and Tips • Debugging – Use scripts to dump form and session variables • Write scripts to dump data to discover bad or missing data
  • 36. Tricks and TipsTricks and Tips • Development Tools – Color coding editors • vim, Emacs, Visual SlickEdit – IDEs • Windows – Macromedia Dreamweaver – Allaire Homesite – Zend’s PHPEdit • Linux – ???
  • 37. PHP 5PHP 5 • Release Date – ??? • Features – Complete objects • Objects with constructors • Abstract classes • Private, protected and abstract functions • Private, protected and constant variables • Namespaces • Exception handling with try/catch blocks
  • 38. ResourcesResources • PHP Downloads and Online Documentation – www.php.net • Community – www.phpbuilder.com: articles on PHP, discussion forums – www.phpresourceindex.com: over 1,000 PHP scripts – www.phpvolcano.com: PHP 5 information • Newsgroups – comp.lang.php
  • 39. Questions?Questions? – Any Questions • www.php.net – Community • www.phpbuilder.com: articles on PHP, discussion forums – Newsgroups • comp.lang.php