SlideShare a Scribd company logo
1 of 40
PHP TUTORIAL BY CYBER
SECURITY INFOTECH (CSI)
http://www.csinfotech.org/
About the company :
 Cs-infotech is one of the best cyber security and website
development company in India. we also provide Network
security, software development, Cyber security
corporate training and SEO and SMO services.
 Our services are Employee Monitoring System,
Employee Monitoring Software, Website Audit , Network
Security , Network Audit and Information Security.
Agenda
 Introduction
 PHP Language Basics
 Built-in Functions
 PHP on Linux and Windows
 Tricks and Tips
 PHP 5
 Examples
 Questions?
Introduction
 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
Introduction
 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
Introduction
 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
Introduction
 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
Introduction
 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
Introduction
 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
Introduction
 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
Introduction
 Netcraft Statistics
 11,869,645 Domains, 1,316,288 IP Addresses
Introduction
 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
PHP Language Basics
 The Script Tags
 All PHP code is contained in one of several script
tags:
 <?
// Some code
?>
 <?php
// Some code here
?>
PHP 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 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 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 Basics
 Hello World!: An Example (cont.)
 <script language=“PHP”>
$hello = “Hello”;
$world = “World!”;
print $hello . $world
</script>
PHP 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 Basics
 Constants, Data Types and Variables
 Using a constant
 print(“Company name: “ . COMPANY . NL);
PHP 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 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 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 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 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 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 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 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 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 Functions
 What comes In the box?
 Database Functions
 dba: dbm-style abstraction layer
 dBase
 Frontbase
 Informix
 Ingres II
 Interbase
 mSQL
Built-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 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 and Windows
 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 and Windows
 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 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 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 Tips
 Debugging
 Use scripts to dump form and session variables
 Write scripts to dump data to discover bad or missing
data
Tricks and Tips
 Development Tools
 Color coding editors
 vim, Emacs, Visual SlickEdit
 IDEs
 Windows
 Macromedia Dreamweaver
 Allaire Homesite
 Zend’s PHPEdit
 Linux
 ???
PHP 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
Resources
 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
Thank you …

More Related Content

Viewers also liked

Employee Management System
Employee Management SystemEmployee Management System
Employee Management SystemAnjali Agrawal
 
Social Networking Project (website) full documentation
Social Networking Project (website) full documentation Social Networking Project (website) full documentation
Social Networking Project (website) full documentation Tenzin Tendar
 
Pizza hut final ppt
Pizza hut final pptPizza hut final ppt
Pizza hut final pptWasim Akram
 
Employee Management System
Employee Management SystemEmployee Management System
Employee Management Systemvivek shah
 

Viewers also liked (8)

FINAL YEAR PROJECT
FINAL YEAR PROJECTFINAL YEAR PROJECT
FINAL YEAR PROJECT
 
Employee Management System
Employee Management SystemEmployee Management System
Employee Management System
 
Social Networking Project (website) full documentation
Social Networking Project (website) full documentation Social Networking Project (website) full documentation
Social Networking Project (website) full documentation
 
Pizza hut final ppt
Pizza hut final pptPizza hut final ppt
Pizza hut final ppt
 
pizza hut-report
pizza hut-reportpizza hut-report
pizza hut-report
 
Basic of PHP
Basic of PHPBasic of PHP
Basic of PHP
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Employee Management System
Employee Management SystemEmployee Management System
Employee Management System
 

More from Cyber Security Infotech Pvt. Ltd. (11)

Enterprises resource planning
Enterprises resource planningEnterprises resource planning
Enterprises resource planning
 
Fee management system
Fee management systemFee management system
Fee management system
 
Hospital management software
Hospital management softwareHospital management software
Hospital management software
 
Hr resource management
Hr resource managementHr resource management
Hr resource management
 
Inventory management software
Inventory management softwareInventory management software
Inventory management software
 
School mangmt system
School mangmt systemSchool mangmt system
School mangmt system
 
Cyber security infotech pvt ltd
Cyber security infotech pvt ltdCyber security infotech pvt ltd
Cyber security infotech pvt ltd
 
DAC2017 - Delhi Art Competition 2017
DAC2017 - Delhi Art Competition 2017DAC2017 - Delhi Art Competition 2017
DAC2017 - Delhi Art Competition 2017
 
How unified threat management (utm) can benefit your enterprise network envir...
How unified threat management (utm) can benefit your enterprise network envir...How unified threat management (utm) can benefit your enterprise network envir...
How unified threat management (utm) can benefit your enterprise network envir...
 
Training on php by cyber security infotech (csi)
Training on  php by cyber security infotech (csi)Training on  php by cyber security infotech (csi)
Training on php by cyber security infotech (csi)
 
Cyber security infotech profile
Cyber security infotech profileCyber security infotech profile
Cyber security infotech profile
 

Recently uploaded

Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!Memoori
 
Revolutionizing SAP® Processes with Automation and Artificial Intelligence
Revolutionizing SAP® Processes with Automation and Artificial IntelligenceRevolutionizing SAP® Processes with Automation and Artificial Intelligence
Revolutionizing SAP® Processes with Automation and Artificial IntelligencePrecisely
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?Paolo Missier
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfalexjohnson7307
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPTiSEO AI
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxjbellis
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfAnubhavMangla3
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandIES VE
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfSrushith Repakula
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityVictorSzoltysek
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 

Recently uploaded (20)

Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Revolutionizing SAP® Processes with Automation and Artificial Intelligence
Revolutionizing SAP® Processes with Automation and Artificial IntelligenceRevolutionizing SAP® Processes with Automation and Artificial Intelligence
Revolutionizing SAP® Processes with Automation and Artificial Intelligence
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 

Php tutorial by cyber security infotech(csi)

  • 1. PHP TUTORIAL BY CYBER SECURITY INFOTECH (CSI) http://www.csinfotech.org/
  • 2. About the company :  Cs-infotech is one of the best cyber security and website development company in India. we also provide Network security, software development, Cyber security corporate training and SEO and SMO services.  Our services are Employee Monitoring System, Employee Monitoring Software, Website Audit , Network Security , Network Audit and Information Security.
  • 3. Agenda  Introduction  PHP Language Basics  Built-in Functions  PHP on Linux and Windows  Tricks and Tips  PHP 5  Examples  Questions?
  • 4. Introduction  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
  • 5. Introduction  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
  • 6. Introduction  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
  • 7. Introduction  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
  • 8. Introduction  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
  • 9. Introduction  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
  • 10. Introduction  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
  • 11. Introduction  Netcraft Statistics  11,869,645 Domains, 1,316,288 IP Addresses
  • 12. Introduction  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
  • 13. PHP Language Basics  The Script Tags  All PHP code is contained in one of several script tags:  <? // Some code ?>  <?php // Some code here ?>
  • 14. PHP 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 %>
  • 15. PHP 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>
  • 16. PHP 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?>
  • 17. PHP Language Basics  Hello World!: An Example (cont.)  <script language=“PHP”> $hello = “Hello”; $world = “World!”; print $hello . $world </script>
  • 18. PHP 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”);
  • 19. PHP Language Basics  Constants, Data Types and Variables  Using a constant  print(“Company name: “ . COMPANY . NL);
  • 20. PHP 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
  • 21. PHP 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
  • 22. PHP 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;
  • 23. PHP 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 ?>
  • 24. PHP 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
  • 25. PHP 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
  • 26. Built-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
  • 27. Built-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
  • 28. Built-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)
  • 29. Built-in Functions  What comes In the box?  Database Functions  dba: dbm-style abstraction layer  dBase  Frontbase  Informix  Ingres II  Interbase  mSQL
  • 30. Built-in Functions  What comes In the box?  Database Functions (cont.)  MySQL  Oracle  PostgreSQL  SQL Server  MING  Macromedia Flash  PDF  Create/manipulate PDF files dynamically
  • 31. Built-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
  • 32. PHP on Linux and Windows  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"; }
  • 33. PHP on Linux and Windows  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";
  • 34. Tricks 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
  • 35. Tricks 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
  • 36. Tricks and Tips  Debugging  Use scripts to dump form and session variables  Write scripts to dump data to discover bad or missing data
  • 37. Tricks and Tips  Development Tools  Color coding editors  vim, Emacs, Visual SlickEdit  IDEs  Windows  Macromedia Dreamweaver  Allaire Homesite  Zend’s PHPEdit  Linux  ???
  • 38. PHP 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
  • 39. Resources  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