SlideShare a Scribd company logo
Developing WebDeveloping Web
Applications with PHPApplications with PHP
RAD for the World
Wide Web
http://cssfounder.com
CssFounder.com
Website For Everyone
AgendaAgenda
– Introduction
– PHP Language Basics
– Built-in Functions
– PHP on Linux and Windows
– Tricks and Tips
– PHP 5
– Examples
– Questions? http://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
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 syntaxhttp://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
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 applicationshttp://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
IntroductionIntroduction
• Netcraft Statistics
– 11,869,645 Domains, 1,316,288 IP Addresses
http://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
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
?>
http://cssfounder.com
CssFounder.com
Website For Everyone
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
%>
http://cssfounder.com
CssFounder.com
Website For Everyone
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>
http://cssfounder.com
CssFounder.com
Website For Everyone
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?>
http://cssfounder.com
CssFounder.com
Website For Everyone
PHP Language BasicsPHP Language Basics
• Hello World!: An Example (cont.)
• <script language=“PHP”>
$hello = “Hello”;
$world = “World!”;
print $hello . $world
</script>
http://cssfounder.com
CssFounder.com
Website For Everyone
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”);
http://cssfounder.com
CssFounder.com
Website For Everyone
PHP Language BasicsPHP Language Basics
• Constants, Data Types and
Variables
– Using a constant
• print(“Company name: “ . COMPANY . NL);
http://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
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;
http://cssfounder.com
CssFounder.com
Website For Everyone
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
?>
http://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
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 reusehttp://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
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 fileshttp://cssfounder.com
CssFounder.com
Website For Everyone
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)
http://cssfounder.com
CssFounder.com
Website For Everyone
Built-in FunctionsBuilt-in Functions
• What comes In the box?
– Database Functions
• dba: dbm-style abstraction layer
• dBase
• Frontbase
• Informix
• Ingres II
• Interbase
• mSQL http://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
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";
}
http://cssfounder.com
CssFounder.com
Website For Everyone
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";http://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
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 http://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
Tricks and TipsTricks and Tips
• Development Tools
– Color coding editors
• vim, Emacs, Visual SlickEdit
– IDEs
• Windows
– Macromedia Dreamweaver
– Allaire Homesite
– Zend’s PHPEdit
• Linux
– ???
http://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
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
http://cssfounder.com
CssFounder.com
Website For Everyone
Questions?Questions?
– Any Questions
• www.php.net
– Community
• www.phpbuilder.com: articles on PHP,
discussion forums
– Newsgroups
• comp.lang.php
http://cssfounder.com
CssFounder.com
Website For Everyone

More Related Content

PPT
Synapse india reviews on php website development
PPT
Phpwebdev
PDF
NewBCamp09: Turning your design into a WordPress Theme
KEY
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
PPTX
PHP language presentation
PDF
Software Development with Open Source
PDF
Top ten-list
PPT
PHP - Introduction to PHP Fundamentals
Synapse india reviews on php website development
Phpwebdev
NewBCamp09: Turning your design into a WordPress Theme
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
PHP language presentation
Software Development with Open Source
Top ten-list
PHP - Introduction to PHP Fundamentals

What's hot (20)

PDF
Introduction to CouchDB
PDF
Introduction to Drupal (7) Theming
PDF
Slow Database in your PHP stack? Don't blame the DBA!
PDF
LESS is More
PPTX
A look at Drupal 7 Theming
PDF
Drawing the Line with Browser Compatibility
PDF
Flickr Architecture Presentation
PPTX
Amp and higher computing science
PPTX
Php reports sumit
PDF
PHP and databases
PDF
Carrington Theme Framework for WordPress (Refresh Denver)
PDF
Creating And Consuming Web Services In Php 5
KEY
Week 1 (v3)
KEY
PPT
Develop webservice in PHP
KEY
PDF
Sdec2011 shashank-introducing hadoop
ZIP
Sdec2011 Introducing Hadoop
PDF
SDEC2011 Essentials of Pig
ODP
Getting started with Django 1.8
Introduction to CouchDB
Introduction to Drupal (7) Theming
Slow Database in your PHP stack? Don't blame the DBA!
LESS is More
A look at Drupal 7 Theming
Drawing the Line with Browser Compatibility
Flickr Architecture Presentation
Amp and higher computing science
Php reports sumit
PHP and databases
Carrington Theme Framework for WordPress (Refresh Denver)
Creating And Consuming Web Services In Php 5
Week 1 (v3)
Develop webservice in PHP
Sdec2011 shashank-introducing hadoop
Sdec2011 Introducing Hadoop
SDEC2011 Essentials of Pig
Getting started with Django 1.8
Ad

Similar to Website designing company_in_delhi_phpwebdevelopment (20)

PPT
PPT
phpwebdev.ppt
PPT
Intro to PHP for Students and professionals
PPT
PDF
PHP Basics
PPTX
Unit 5-PHP Declaring variables, data types, array, string, operators, Expres...
PPT
Prersentation
PDF
Introduction to php
PDF
basic concept of php(Gunikhan sonowal)
PPT
Phpwebdevelping
PPT
Introduction to web and php mysql
PPTX
Introduction to PHP.pptx
PPT
Synapseindia reviews on array php
PPT
Php intro
PPT
Php intro
PPT
Php intro
PPTX
2016 03 15_biological_databases_part4
PPT
PDF
WT_PHP_PART1.pdf
PDF
Introduction to php
phpwebdev.ppt
Intro to PHP for Students and professionals
PHP Basics
Unit 5-PHP Declaring variables, data types, array, string, operators, Expres...
Prersentation
Introduction to php
basic concept of php(Gunikhan sonowal)
Phpwebdevelping
Introduction to web and php mysql
Introduction to PHP.pptx
Synapseindia reviews on array php
Php intro
Php intro
Php intro
2016 03 15_biological_databases_part4
WT_PHP_PART1.pdf
Introduction to php
Ad

More from Css Founder (20)

PPT
Cssfounder.com website designing company in delhi
PDF
Internet technology and web designing
PPT
Web page design-cssfounder
PPT
Tech dev cssfounder.com
PPT
Digital india-cssfounder.com
PPT
Poverty inindia CssFounder.com
PPT
Poverty in india Cssfounder.com
PPT
Website designing company in delhi e commerce
PPT
Website designing company_in_delhi blogging
PPT
Website designing company in delhi blog powerpoint
PPT
Website designing company_in_delhi e-business
PPTX
Website designing company_in_mumbai_digital india
PPT
Website designing company_in_delhi_digitization practices
PPT
Website designing company_in_delhi_education
PPT
Website designing company_in_delhi_education system
PPT
Website development process
PPT
Webdesign website development_company_surat
PPT
Internet website designing_company_in_delhi
PPT
Website designing company in delhi
PPT
Internet
Cssfounder.com website designing company in delhi
Internet technology and web designing
Web page design-cssfounder
Tech dev cssfounder.com
Digital india-cssfounder.com
Poverty inindia CssFounder.com
Poverty in india Cssfounder.com
Website designing company in delhi e commerce
Website designing company_in_delhi blogging
Website designing company in delhi blog powerpoint
Website designing company_in_delhi e-business
Website designing company_in_mumbai_digital india
Website designing company_in_delhi_digitization practices
Website designing company_in_delhi_education
Website designing company_in_delhi_education system
Website development process
Webdesign website development_company_surat
Internet website designing_company_in_delhi
Website designing company in delhi
Internet

Recently uploaded (20)

PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Approach and Philosophy of On baking technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
cuic standard and advanced reporting.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Programs and apps: productivity, graphics, security and other tools
Understanding_Digital_Forensics_Presentation.pptx
Empathic Computing: Creating Shared Understanding
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Approach and Philosophy of On baking technology
Review of recent advances in non-invasive hemoglobin estimation
Reach Out and Touch Someone: Haptics and Empathic Computing
Chapter 3 Spatial Domain Image Processing.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Unlocking AI with Model Context Protocol (MCP)
20250228 LYD VKU AI Blended-Learning.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Encapsulation_ Review paper, used for researhc scholars
Mobile App Security Testing_ A Comprehensive Guide.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
cuic standard and advanced reporting.pdf

Website designing company_in_delhi_phpwebdevelopment

  • 1. Developing WebDeveloping Web Applications with PHPApplications with PHP RAD for the World Wide Web http://cssfounder.com CssFounder.com Website For Everyone
  • 2. AgendaAgenda – Introduction – PHP Language Basics – Built-in Functions – PHP on Linux and Windows – Tricks and Tips – PHP 5 – Examples – Questions? http://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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 syntaxhttp://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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 applicationshttp://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 10. IntroductionIntroduction • Netcraft Statistics – 11,869,645 Domains, 1,316,288 IP Addresses http://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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 ?> http://cssfounder.com CssFounder.com Website For Everyone
  • 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 %> http://cssfounder.com CssFounder.com Website For Everyone
  • 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> http://cssfounder.com CssFounder.com Website For Everyone
  • 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?> http://cssfounder.com CssFounder.com Website For Everyone
  • 16. PHP Language BasicsPHP Language Basics • Hello World!: An Example (cont.) • <script language=“PHP”> $hello = “Hello”; $world = “World!”; print $hello . $world </script> http://cssfounder.com CssFounder.com Website For Everyone
  • 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”); http://cssfounder.com CssFounder.com Website For Everyone
  • 18. PHP Language BasicsPHP Language Basics • Constants, Data Types and Variables – Using a constant • print(“Company name: “ . COMPANY . NL); http://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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; http://cssfounder.com CssFounder.com Website For Everyone
  • 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 ?> http://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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 reusehttp://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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 fileshttp://cssfounder.com CssFounder.com Website For Everyone
  • 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) http://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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"; } http://cssfounder.com CssFounder.com Website For Everyone
  • 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";http://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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 – ??? http://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 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 http://cssfounder.com CssFounder.com Website For Everyone
  • 39. Questions?Questions? – Any Questions • www.php.net – Community • www.phpbuilder.com: articles on PHP, discussion forums – Newsgroups • comp.lang.php http://cssfounder.com CssFounder.com Website For Everyone