SlideShare une entreprise Scribd logo
1  sur  80
USING PHP


     Peter Brown              Mark Casias
brown.peterg@gmail.com   markie@teampoop.com
      @litescript             @teampoop
PHP IS...

...PHP: Hypertext Pre-processor is a scripting language
used to add dynamic content to web pages.

 ...embedded directly into your HTML code.

...a server-side scripting language, allowing the coder
to ignore browser types/versions/specifications.

...extremely popular!
PHP IS...

...PHP: Hypertext Pre-processor is a scripting language
used to add dynamic content to web pages.

 ...embedded directly into your HTML code.

...a server-side scripting language, allowing the coder
to ignore browser types/versions/specifications.

...extremely popular!
PHP ISN'T...
PHP ISN'T...

...a magic bullet.
PHP ISN'T...

...a magic bullet.

...necessary for every
application.
PHP ISN'T...

...a magic bullet.

...necessary for every
application.

...pure awesome bottled
for your enjoyment after 1
year of conditioning...wait...
SOUNDS GREAT (IT IS) -
  WHAT DO I NEED?
SOUNDS GREAT (IT IS) -
     WHAT DO I NEED?
PHP installed and enabled on your server.
SOUNDS GREAT (IT IS) -
     WHAT DO I NEED?
PHP installed and enabled on your server.

  PHP is open-source and free. Download and install it if
  not already installed on your server.
SOUNDS GREAT (IT IS) -
     WHAT DO I NEED?
PHP installed and enabled on your server.

  PHP is open-source and free. Download and install it if
  not already installed on your server.

Configuration.
SOUNDS GREAT (IT IS) -
     WHAT DO I NEED?
PHP installed and enabled on your server.

  PHP is open-source and free. Download and install it if
  not already installed on your server.

Configuration.

  Usually done for you.
SOUNDS GREAT (IT IS) -
     WHAT DO I NEED?
PHP installed and enabled on your server.

  PHP is open-source and free. Download and install it if
  not already installed on your server.

Configuration.

  Usually done for you.

  PHP set to handle all .php files.
SOUNDS GREAT (IT IS) -
     WHAT DO I NEED?
PHP installed and enabled on your server.

  PHP is open-source and free. Download and install it if
  not already installed on your server.

Configuration.

  Usually done for you.

  PHP set to handle all .php files.

  You can get as intense or simple as you want
  - check the online manual!
SOUNDS GREAT (IT IS) -
     WHAT DO I NEED?
PHP installed and enabled on your server.

  PHP is open-source and free. Download and install it if
  not already installed on your server.

Configuration.

  Usually done for you.

  PHP set to handle all .php files.

  You can get as intense or simple as you want
  - check the online manual!

Dashing good looks; debonair attitude. 
WHERE DO I COME FROM?
WHERE DO I COME FROM?

Ask your parents, kid...that ain't my
racket.
WHERE DO I COME FROM?

Ask your parents, kid...that ain't my
racket.

PHP was originally a set of Perl
scripts.
WHERE DO I COME FROM?

Ask your parents, kid...that ain't my
racket.

PHP was originally a set of Perl
scripts.

  Notice the Perl-like syntax, nerds.
WHERE DO I COME FROM?

Ask your parents, kid...that ain't my
racket.

PHP was originally a set of Perl
scripts.

  Notice the Perl-like syntax, nerds.

 Original name, "Personal Home
Page Tools" - PHP Tools.
WHERE DO I COME FROM?

Ask your parents, kid...that ain't my
racket.

PHP was originally a set of Perl
scripts.

  Notice the Perl-like syntax, nerds.

 Original name, "Personal Home
Page Tools" - PHP Tools.

Current PHP version (as of today):
5.3.3
YOUR FIRST PHP
                (subtext: ubiquitous "Hello, world!")
<html>
    <head>
    <title>My First PHP page</title>
    </head>
    <body>
        <?php
            echo ("Bonjour, monde!");
        ?>
    </body>
</html> 
WHAT JUST HAPPENED?
WHAT JUST HAPPENED?
PHP is embedded directly into your HTML.
WHAT JUST HAPPENED?
PHP is embedded directly into your HTML.

Begin "PHP mode" using either <?php or <?
WHAT JUST HAPPENED?
PHP is embedded directly into your HTML.

Begin "PHP mode" using either <?php or <?

exit "PHP mode" using ?>
WHAT JUST HAPPENED?
PHP is embedded directly into your HTML.

Begin "PHP mode" using either <?php or <?

exit "PHP mode" using ?>

What's echo(); ?
WHAT JUST HAPPENED?
PHP is embedded directly into your HTML.

Begin "PHP mode" using either <?php or <?

exit "PHP mode" using ?>

What's echo(); ?

  echo(); or more simply print(); prints to
  screen. (<?=$var?>)
WHAT JUST HAPPENED?
PHP is embedded directly into your HTML.

Begin "PHP mode" using either <?php or <?

exit "PHP mode" using ?>

What's echo(); ?

  echo(); or more simply print(); prints to
  screen. (<?=$var?>)

 The rest is magic!
WHAT JUST HAPPENED?
PHP is embedded directly into your HTML.

Begin "PHP mode" using either <?php or <?

exit "PHP mode" using ?>

What's echo(); ?

  echo(); or more simply print(); prints to
  screen. (<?=$var?>)

 The rest is magic!

  kidding...
LET'S DIVE IN
LET'S DIVE IN
Functions:
LET'S DIVE IN
Functions:

  Basic building blocks.
LET'S DIVE IN
Functions:

  Basic building blocks.

  Create your own; use built in functions (eg, "echo();")
LET'S DIVE IN
Functions:

  Basic building blocks.

  Create your own; use built in functions (eg, "echo();")

  Syntax:
  function thename($arg) {
       // code to execute goes here
  }
LET'S DIVE IN
Functions:

  Basic building blocks.

  Create your own; use built in functions (eg, "echo();")

  Syntax:
  function thename($arg) {
       // code to execute goes here
  }

  To call your function: thename();
LET'S DIVE IN
Functions:

  Basic building blocks.

  Create your own; use built in functions (eg, "echo();")

  Syntax:
  function thename($arg) {
       // code to execute goes here
  }

  To call your function: thename();

Variables (super easy): $variablename;
FORMS
FORMS
Get some info!
<form name="login" action="script.php" method=”post”>
     <input type="text" name="userid" />
     <input type="password" name="pass" />
</form>
FORMS
Get some info!
<form name="login" action="script.php" method=”post”>
     <input type="text" name="userid" />
     <input type="password" name="pass" />
</form>

OK that's great...nice form buddy.
FORMS
Get some info!
<form name="login" action="script.php" method=”post”>
     <input type="text" name="userid" />
     <input type="password" name="pass" />
</form>

OK that's great...nice form buddy.

  First of all: calm down.
FORMS
Get some info!
<form name="login" action="script.php" method=”post”>
     <input type="text" name="userid" />
     <input type="password" name="pass" />
</form>

OK that's great...nice form buddy.

  First of all: calm down.
  This is useful! name="" is your variable name.
FORMS
Get some info!
<form name="login" action="script.php" method=”post”>
     <input type="text" name="userid" />
     <input type="password" name="pass" />
</form>

OK that's great...nice form buddy.

  First of all: calm down.
  This is useful! name="" is your variable name.
  eg: <?php $userid; $pass; ?>
FORMS
Get some info!
<form name="login" action="script.php" method=”post”>
     <input type="text" name="userid" />
     <input type="password" name="pass" />
</form>

OK that's great...nice form buddy.

  First of all: calm down.
  This is useful! name="" is your variable name.
  eg: <?php $userid; $pass; ?>
  OOOOOORRRR you need a SUPER VARIABLE!
  $_REQUEST, $_POST, $_MOM
TIME TO DROWN
   
   
               TIME TO DROWN
         
         
             
                 

           
       
       
   
   


   


   

   
   
   
               TIME TO DROWN
         
         
             
                 

           
       
                    - What's going on here?! 
   
                    - Baby, let me explain...
   


   

   
   
   
               TIME TO DROWN
         
         
             
                 

           
       
       
   
   


   


   

   
GET SOME CLASS
GET SOME CLASS
Classes are PHP’s Objects
GET SOME CLASS
Classes are PHP’s Objects

Contains variables and methods (functions)
GET SOME CLASS
Classes are PHP’s Objects

Contains variables and methods (functions)

Private or Public methods/variables.
GET SOME CLASS
Classes are PHP’s Objects

Contains variables and methods (functions)

Private or Public methods/variables.

Sample Class:
GET SOME CLASS
Classes are PHP’s Objects

Contains variables and methods (functions)

Private or Public methods/variables.

Sample Class:
         class Foo {
GET SOME CLASS
Classes are PHP’s Objects

Contains variables and methods (functions)

Private or Public methods/variables.

Sample Class:
         class Foo {
            public $fighters = ‘good’;
GET SOME CLASS
Classes are PHP’s Objects

Contains variables and methods (functions)

Private or Public methods/variables.

Sample Class:
         class Foo {
            public $fighters = ‘good’;
            private $nirvana = ‘dead’;
GET SOME CLASS
Classes are PHP’s Objects

Contains variables and methods (functions)

Private or Public methods/variables.

Sample Class:
         class Foo {
            public $fighters = ‘good’;
            private $nirvana = ‘dead’;
            public breath($arg) {
GET SOME CLASS
Classes are PHP’s Objects

Contains variables and methods (functions)

Private or Public methods/variables.

Sample Class:
         class Foo {
            public $fighters = ‘good’;
            private $nirvana = ‘dead’;
            public breath($arg) {
               $this->nirvana=‘alive’;
GET SOME CLASS
Classes are PHP’s Objects

Contains variables and methods (functions)

Private or Public methods/variables.

Sample Class:
         class Foo {
            public $fighters = ‘good’;
            private $nirvana = ‘dead’;
            public breath($arg) {
               $this->nirvana=‘alive’;
            }
GET SOME CLASS
Classes are PHP’s Objects

Contains variables and methods (functions)

Private or Public methods/variables.

Sample Class:
         class Foo {
            public $fighters = ‘good’;
            private $nirvana = ‘dead’;
            public breath($arg) {
               $this->nirvana=‘alive’;
            }
         }
GET SOME CLASS
Classes are PHP’s Objects

Contains variables and methods (functions)

Private or Public methods/variables.

Sample Class:
         class Foo {
            public $fighters = ‘good’;
            private $nirvana = ‘dead’;
            public breath($arg) {
               $this->nirvana=‘alive’;
            }
         }
DATABASE CONNECTABLES
DATABASE CONNECTABLES

PHP Supports MOST database connections
MySQL, Oracle (OCI8), Postgres, Sybase
DATABASE CONNECTABLES

PHP Supports MOST database connections
MySQL, Oracle (OCI8), Postgres, Sybase

First, it connects to the database.
DATABASE CONNECTABLES

PHP Supports MOST database connections
MySQL, Oracle (OCI8), Postgres, Sybase

First, it connects to the database.

Second, it makes it’s SQL query in the flavor.
DATABASE CONNECTABLES

PHP Supports MOST database connections
MySQL, Oracle (OCI8), Postgres, Sybase

First, it connects to the database.

Second, it makes it’s SQL query in the flavor.

It puts the lotion in the bucket.
DATABASE CONNECTABLES

PHP Supports MOST database connections
MySQL, Oracle (OCI8), Postgres, Sybase

First, it connects to the database.

Second, it makes it’s SQL query in the flavor.

It puts the lotion in the bucket.

Err I mean: a result set of information returns.
EXAMPLE
EXAMPLE
EXAMPLE
<?php
mysql_connect(localhost,$username,$password);
$query = "SELECT * FROM SEWINGPLANS";
$bucket = mysql_query($query);

mysql_close();
MORE DB FUN
MORE DB FUN


Take the resource, and use it.
<?php
 while($bucketArray = mysql_fetch_array($bucket)):
   echo “$bucketArray[‘skintype’];
 endwhile;
MORE DB FUN


Take the resource, and use it.
<?php
 while($bucketArray = mysql_fetch_array($bucket)):
   echo “$bucketArray[‘skintype’];
 endwhile;

You could also make objects out of each row.
PHP PLATFORMS


Yes, I am in fact, a broken record.

Many out there in the world.
Zend - Granddaddy of them. Many server solutions
CakePHP - MCV implementation
CodeIgniter - Better.

And many many more
CODE IGNITER
                            WIN


Best documentation out of all

Easiest Model... err.. model
You don’t have to conform your
data model to their will.

Full MCV implementation.

PHP Best Practices!


http://codeigniter.com/user_guide/general/styleguide.html
CONFIGURATION


View config with phpinfo();

php.ini file

.htaccess files

ini_set() function
TRULY SCARY!
TRULY SCARY!
TRULY SCARY!



 The End
TRULY SCARY!

Contenu connexe

Tendances (20)

Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
PHP Workshop Notes
PHP Workshop NotesPHP Workshop Notes
PHP Workshop Notes
 
PHP - Introduction to PHP
PHP -  Introduction to PHPPHP -  Introduction to PHP
PHP - Introduction to PHP
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Data Types In PHP
Data Types In PHPData Types In PHP
Data Types In PHP
 
Intro to php
Intro to phpIntro to php
Intro to php
 
HackU PHP and Node.js
HackU PHP and Node.jsHackU PHP and Node.js
HackU PHP and Node.js
 
Php hacku
Php hackuPhp hacku
Php hacku
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHP
 
Intro to PHP
Intro to PHPIntro to PHP
Intro to PHP
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
 
Intermediate PHP
Intermediate PHPIntermediate PHP
Intermediate PHP
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
PHP MySQL Workshop - facehook
PHP MySQL Workshop - facehookPHP MySQL Workshop - facehook
PHP MySQL Workshop - facehook
 
What Is Php
What Is PhpWhat Is Php
What Is Php
 
Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04
 
Introduction to php web programming - get and post
Introduction to php  web programming - get and postIntroduction to php  web programming - get and post
Introduction to php web programming - get and post
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 

Similaire à Using PHP (20)

Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13
 
Php Tutorial | Introduction Demo | Basics
 Php Tutorial | Introduction Demo | Basics Php Tutorial | Introduction Demo | Basics
Php Tutorial | Introduction Demo | Basics
 
Learning of Php and My SQL Tutorial | For Beginners
Learning of Php and My SQL Tutorial | For BeginnersLearning of Php and My SQL Tutorial | For Beginners
Learning of Php and My SQL Tutorial | For Beginners
 
Php My SQL Tutorial | beginning
Php My SQL Tutorial | beginningPhp My SQL Tutorial | beginning
Php My SQL Tutorial | beginning
 
PHP: The easiest language to learn.
PHP: The easiest language to learn.PHP: The easiest language to learn.
PHP: The easiest language to learn.
 
Lecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdfLecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdf
 
PHP Doesn't Suck
PHP Doesn't SuckPHP Doesn't Suck
PHP Doesn't Suck
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 
Php
PhpPhp
Php
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
Upstate CSCI 450 PHP
Upstate CSCI 450 PHPUpstate CSCI 450 PHP
Upstate CSCI 450 PHP
 
basic concept of php(Gunikhan sonowal)
basic concept of php(Gunikhan sonowal)basic concept of php(Gunikhan sonowal)
basic concept of php(Gunikhan sonowal)
 
PHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERSPHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERS
 
WT_PHP_PART1.pdf
WT_PHP_PART1.pdfWT_PHP_PART1.pdf
WT_PHP_PART1.pdf
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
php basics
php basicsphp basics
php basics
 
Wt unit 4 server side technology-2
Wt unit 4 server side technology-2Wt unit 4 server side technology-2
Wt unit 4 server side technology-2
 
Php mysql training-in-mumbai
Php mysql training-in-mumbaiPhp mysql training-in-mumbai
Php mysql training-in-mumbai
 
PHP Lesson
PHP LessonPHP Lesson
PHP Lesson
 

Plus de Mark Casias

Backing yourself into an Accessible Corner
Backing yourself into an Accessible CornerBacking yourself into an Accessible Corner
Backing yourself into an Accessible CornerMark Casias
 
Backend accessible
Backend accessibleBackend accessible
Backend accessibleMark Casias
 
Constantly Contributing Pretty Patches FLCD
Constantly Contributing Pretty Patches FLCDConstantly Contributing Pretty Patches FLCD
Constantly Contributing Pretty Patches FLCDMark Casias
 
ABQ Drupal Users Group Presentation 2014/07/10
ABQ Drupal Users Group Presentation 2014/07/10ABQ Drupal Users Group Presentation 2014/07/10
ABQ Drupal Users Group Presentation 2014/07/10Mark Casias
 
Something drupal this way comes
Something drupal this way comesSomething drupal this way comes
Something drupal this way comesMark Casias
 
Spiffy Applications With JavaScript
Spiffy Applications With JavaScriptSpiffy Applications With JavaScript
Spiffy Applications With JavaScriptMark Casias
 
Idiots guide to jquery
Idiots guide to jqueryIdiots guide to jquery
Idiots guide to jqueryMark Casias
 
Libraries Frameworks And Cms
Libraries Frameworks And CmsLibraries Frameworks And Cms
Libraries Frameworks And CmsMark Casias
 

Plus de Mark Casias (8)

Backing yourself into an Accessible Corner
Backing yourself into an Accessible CornerBacking yourself into an Accessible Corner
Backing yourself into an Accessible Corner
 
Backend accessible
Backend accessibleBackend accessible
Backend accessible
 
Constantly Contributing Pretty Patches FLCD
Constantly Contributing Pretty Patches FLCDConstantly Contributing Pretty Patches FLCD
Constantly Contributing Pretty Patches FLCD
 
ABQ Drupal Users Group Presentation 2014/07/10
ABQ Drupal Users Group Presentation 2014/07/10ABQ Drupal Users Group Presentation 2014/07/10
ABQ Drupal Users Group Presentation 2014/07/10
 
Something drupal this way comes
Something drupal this way comesSomething drupal this way comes
Something drupal this way comes
 
Spiffy Applications With JavaScript
Spiffy Applications With JavaScriptSpiffy Applications With JavaScript
Spiffy Applications With JavaScript
 
Idiots guide to jquery
Idiots guide to jqueryIdiots guide to jquery
Idiots guide to jquery
 
Libraries Frameworks And Cms
Libraries Frameworks And CmsLibraries Frameworks And Cms
Libraries Frameworks And Cms
 

Dernier

A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Dernier (20)

A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Using PHP

  • 1. USING PHP Peter Brown Mark Casias brown.peterg@gmail.com markie@teampoop.com @litescript @teampoop
  • 2. PHP IS... ...PHP: Hypertext Pre-processor is a scripting language used to add dynamic content to web pages.  ...embedded directly into your HTML code. ...a server-side scripting language, allowing the coder to ignore browser types/versions/specifications. ...extremely popular!
  • 3. PHP IS... ...PHP: Hypertext Pre-processor is a scripting language used to add dynamic content to web pages.  ...embedded directly into your HTML code. ...a server-side scripting language, allowing the coder to ignore browser types/versions/specifications. ...extremely popular!
  • 6. PHP ISN'T... ...a magic bullet. ...necessary for every application.
  • 7. PHP ISN'T... ...a magic bullet. ...necessary for every application. ...pure awesome bottled for your enjoyment after 1 year of conditioning...wait...
  • 8. SOUNDS GREAT (IT IS) - WHAT DO I NEED?
  • 9. SOUNDS GREAT (IT IS) - WHAT DO I NEED? PHP installed and enabled on your server.
  • 10. SOUNDS GREAT (IT IS) - WHAT DO I NEED? PHP installed and enabled on your server. PHP is open-source and free. Download and install it if not already installed on your server.
  • 11. SOUNDS GREAT (IT IS) - WHAT DO I NEED? PHP installed and enabled on your server. PHP is open-source and free. Download and install it if not already installed on your server. Configuration.
  • 12. SOUNDS GREAT (IT IS) - WHAT DO I NEED? PHP installed and enabled on your server. PHP is open-source and free. Download and install it if not already installed on your server. Configuration. Usually done for you.
  • 13. SOUNDS GREAT (IT IS) - WHAT DO I NEED? PHP installed and enabled on your server. PHP is open-source and free. Download and install it if not already installed on your server. Configuration. Usually done for you. PHP set to handle all .php files.
  • 14. SOUNDS GREAT (IT IS) - WHAT DO I NEED? PHP installed and enabled on your server. PHP is open-source and free. Download and install it if not already installed on your server. Configuration. Usually done for you. PHP set to handle all .php files. You can get as intense or simple as you want - check the online manual!
  • 15. SOUNDS GREAT (IT IS) - WHAT DO I NEED? PHP installed and enabled on your server. PHP is open-source and free. Download and install it if not already installed on your server. Configuration. Usually done for you. PHP set to handle all .php files. You can get as intense or simple as you want - check the online manual! Dashing good looks; debonair attitude. 
  • 16. WHERE DO I COME FROM?
  • 17. WHERE DO I COME FROM? Ask your parents, kid...that ain't my racket.
  • 18. WHERE DO I COME FROM? Ask your parents, kid...that ain't my racket. PHP was originally a set of Perl scripts.
  • 19. WHERE DO I COME FROM? Ask your parents, kid...that ain't my racket. PHP was originally a set of Perl scripts. Notice the Perl-like syntax, nerds.
  • 20. WHERE DO I COME FROM? Ask your parents, kid...that ain't my racket. PHP was originally a set of Perl scripts. Notice the Perl-like syntax, nerds.  Original name, "Personal Home Page Tools" - PHP Tools.
  • 21. WHERE DO I COME FROM? Ask your parents, kid...that ain't my racket. PHP was originally a set of Perl scripts. Notice the Perl-like syntax, nerds.  Original name, "Personal Home Page Tools" - PHP Tools. Current PHP version (as of today): 5.3.3
  • 22. YOUR FIRST PHP (subtext: ubiquitous "Hello, world!") <html>     <head>     <title>My First PHP page</title>     </head>     <body>         <?php             echo ("Bonjour, monde!");         ?>     </body> </html> 
  • 24. WHAT JUST HAPPENED? PHP is embedded directly into your HTML.
  • 25. WHAT JUST HAPPENED? PHP is embedded directly into your HTML. Begin "PHP mode" using either <?php or <?
  • 26. WHAT JUST HAPPENED? PHP is embedded directly into your HTML. Begin "PHP mode" using either <?php or <? exit "PHP mode" using ?>
  • 27. WHAT JUST HAPPENED? PHP is embedded directly into your HTML. Begin "PHP mode" using either <?php or <? exit "PHP mode" using ?> What's echo(); ?
  • 28. WHAT JUST HAPPENED? PHP is embedded directly into your HTML. Begin "PHP mode" using either <?php or <? exit "PHP mode" using ?> What's echo(); ? echo(); or more simply print(); prints to screen. (<?=$var?>)
  • 29. WHAT JUST HAPPENED? PHP is embedded directly into your HTML. Begin "PHP mode" using either <?php or <? exit "PHP mode" using ?> What's echo(); ? echo(); or more simply print(); prints to screen. (<?=$var?>)  The rest is magic!
  • 30. WHAT JUST HAPPENED? PHP is embedded directly into your HTML. Begin "PHP mode" using either <?php or <? exit "PHP mode" using ?> What's echo(); ? echo(); or more simply print(); prints to screen. (<?=$var?>)  The rest is magic! kidding...
  • 33. LET'S DIVE IN Functions: Basic building blocks.
  • 34. LET'S DIVE IN Functions: Basic building blocks. Create your own; use built in functions (eg, "echo();")
  • 35. LET'S DIVE IN Functions: Basic building blocks. Create your own; use built in functions (eg, "echo();") Syntax: function thename($arg) {      // code to execute goes here }
  • 36. LET'S DIVE IN Functions: Basic building blocks. Create your own; use built in functions (eg, "echo();") Syntax: function thename($arg) {      // code to execute goes here } To call your function: thename();
  • 37. LET'S DIVE IN Functions: Basic building blocks. Create your own; use built in functions (eg, "echo();") Syntax: function thename($arg) {      // code to execute goes here } To call your function: thename(); Variables (super easy): $variablename;
  • 38. FORMS
  • 39. FORMS Get some info! <form name="login" action="script.php" method=”post”>      <input type="text" name="userid" />      <input type="password" name="pass" /> </form>
  • 40. FORMS Get some info! <form name="login" action="script.php" method=”post”>      <input type="text" name="userid" />      <input type="password" name="pass" /> </form> OK that's great...nice form buddy.
  • 41. FORMS Get some info! <form name="login" action="script.php" method=”post”>      <input type="text" name="userid" />      <input type="password" name="pass" /> </form> OK that's great...nice form buddy. First of all: calm down.
  • 42. FORMS Get some info! <form name="login" action="script.php" method=”post”>      <input type="text" name="userid" />      <input type="password" name="pass" /> </form> OK that's great...nice form buddy. First of all: calm down. This is useful! name="" is your variable name.
  • 43. FORMS Get some info! <form name="login" action="script.php" method=”post”>      <input type="text" name="userid" />      <input type="password" name="pass" /> </form> OK that's great...nice form buddy. First of all: calm down. This is useful! name="" is your variable name. eg: <?php $userid; $pass; ?>
  • 44. FORMS Get some info! <form name="login" action="script.php" method=”post”>      <input type="text" name="userid" />      <input type="password" name="pass" /> </form> OK that's great...nice form buddy. First of all: calm down. This is useful! name="" is your variable name. eg: <?php $userid; $pass; ?> OOOOOORRRR you need a SUPER VARIABLE! $_REQUEST, $_POST, $_MOM
  • 46.         TIME TO DROWN                                                                                            
  • 47.         TIME TO DROWN                                                                         - What's going on here?!          - Baby, let me explain...            
  • 48.         TIME TO DROWN                                                                                            
  • 50. GET SOME CLASS Classes are PHP’s Objects
  • 51. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions)
  • 52. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables.
  • 53. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class:
  • 54. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo {
  • 55. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo { public $fighters = ‘good’;
  • 56. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo { public $fighters = ‘good’; private $nirvana = ‘dead’;
  • 57. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo { public $fighters = ‘good’; private $nirvana = ‘dead’; public breath($arg) {
  • 58. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo { public $fighters = ‘good’; private $nirvana = ‘dead’; public breath($arg) { $this->nirvana=‘alive’;
  • 59. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo { public $fighters = ‘good’; private $nirvana = ‘dead’; public breath($arg) { $this->nirvana=‘alive’; }
  • 60. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo { public $fighters = ‘good’; private $nirvana = ‘dead’; public breath($arg) { $this->nirvana=‘alive’; } }
  • 61. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo { public $fighters = ‘good’; private $nirvana = ‘dead’; public breath($arg) { $this->nirvana=‘alive’; } }
  • 63. DATABASE CONNECTABLES PHP Supports MOST database connections MySQL, Oracle (OCI8), Postgres, Sybase
  • 64. DATABASE CONNECTABLES PHP Supports MOST database connections MySQL, Oracle (OCI8), Postgres, Sybase First, it connects to the database.
  • 65. DATABASE CONNECTABLES PHP Supports MOST database connections MySQL, Oracle (OCI8), Postgres, Sybase First, it connects to the database. Second, it makes it’s SQL query in the flavor.
  • 66. DATABASE CONNECTABLES PHP Supports MOST database connections MySQL, Oracle (OCI8), Postgres, Sybase First, it connects to the database. Second, it makes it’s SQL query in the flavor. It puts the lotion in the bucket.
  • 67. DATABASE CONNECTABLES PHP Supports MOST database connections MySQL, Oracle (OCI8), Postgres, Sybase First, it connects to the database. Second, it makes it’s SQL query in the flavor. It puts the lotion in the bucket. Err I mean: a result set of information returns.
  • 70. EXAMPLE <?php mysql_connect(localhost,$username,$password); $query = "SELECT * FROM SEWINGPLANS"; $bucket = mysql_query($query); mysql_close();
  • 72. MORE DB FUN Take the resource, and use it. <?php while($bucketArray = mysql_fetch_array($bucket)): echo “$bucketArray[‘skintype’]; endwhile;
  • 73. MORE DB FUN Take the resource, and use it. <?php while($bucketArray = mysql_fetch_array($bucket)): echo “$bucketArray[‘skintype’]; endwhile; You could also make objects out of each row.
  • 74. PHP PLATFORMS Yes, I am in fact, a broken record. Many out there in the world. Zend - Granddaddy of them. Many server solutions CakePHP - MCV implementation CodeIgniter - Better. And many many more
  • 75. CODE IGNITER WIN Best documentation out of all Easiest Model... err.. model You don’t have to conform your data model to their will. Full MCV implementation. PHP Best Practices! http://codeigniter.com/user_guide/general/styleguide.html
  • 76. CONFIGURATION View config with phpinfo(); php.ini file .htaccess files ini_set() function

Notes de l'éditeur