SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler offline
Getting Started
with PHP
MemphisPHP.org
Joe Ferguson - joe@joeferguson.me
Professionally
● Web Developer at RocketFuel
● PHP / LAMP Focused
Semi Professional
● Co-Organizer for MemphisPHP.org
● MidsouthMakers - Hackerspace Leader
● HACKmemphis.com Organizer
Who is this guy?
It’s a recursive anagram…
PHP: Hypertext Preprocessor is a widely used, general-
purpose scripting language that was originally designed
for web development to produce dynamic web pages
What is PHP?
● Widespread Availability
○ PHP is now installed on more than 244 million
websites and 2.1 million web servers (Source:
Wikipedia)
● Ease of use.
○ Extremely simple for newcomers
○ Advanced features for professional programmers
○ Looslely typed
● Great Community Support
● Many corporations throwing support
behind PHP projects
Why use PHP?
Who uses it? What runs on PHP?
...and many, MANY others
<html>
<head>
<title>Example 1 - Getting Started with
PHP<</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
Jumping into PHP - Example 1
You can add any content to a PHP file.
Anything not between PHP tags is ignored by
PHP.
Using echo, you can print from PHP. As
example 1 shows, even PHP.
Example 1 - Basic HTML + PHP
PHP is very easy to pick up and run with.
This is one of the main reasons it is so
widespread.
Looks easy right?
$_GET Variables come from the URL
Bad:
<?php
$name = $_GET['name'];
?>
NEVER trust data from your users!
Good:
<?php
if(isset($_GET['name'])){
$name = filter_var($_GET['name'],FILTER_SANITIZE_STRING);
}
?>
Getting Data from the User
So what is happening?
● First we check if the name exists by
looking at $_GET[‘name’]
○ if(isset($_GET['name'])){
● If it does exist, we pass it to a function to
sanitize the input and set the results equal
to $name
○ $name = filter_var($_GET['name'],FILTER_SANITIZE_STRING);
Getting Data from the User
● isset
● empty
● filter_var
● arrays
● strings
● omgwtf!
The best PHP resources:
● phptherightway.com
● php.net
I can’t keep track of all this!
PHP Specification Request (PSR)
The Framework Interop Group:
● PSR-0
● PSR-1
● PSR-2
Other Styles:
● PEAR Coding Standards
● Zend Coding Standards
OMG your { are on the wrong line!
There are subtle differences among the PSR
coding styles approved by the FIG.
If you’re wanting to maximize your
reusability: pick a PSR similar to the code
you are working with.
Most projects won’t take code if it doesn’t
match the style they have adopted.
Why so many? What do I use?
Strings
● echo ‘PHP is my favorite language’;
● $variable = ‘PHP is amazing’;
● echo "PHP! you'll be astonished";
● echo 'PHP! you'll be astonished';
Concatenation
● echo "Hello, " . $prefix . " " . $name;
Single quote strings do not get parsed.
Double quote strings get parsed. Are slower
than single quote strings because of this.
Before we get too complicated:
Simple Arrays:
<?php
$fruit = array();
$fruit[] = 'apple';
$fruit[] = 'pear';
$fruit[] = 'orange';
$fruit[] = 'lemon';
$fruit[] = 'pineapple';
?>
Arrays - associating values to keys
$food = array();
$food['fruit'] = array();
$food['fruit'][] = 'apple';
$food['fruit'][] = 'pear';
$food['fruit'][] = 'orange';
$food['fruit'][] = 'lemon';
$food['fruit'][] = 'pineapple';
$food['meat'] = array();
$food['meat'][] = 'bacon';
$food['meat'][] = 'steak';
$food['meat'][] = 'chicken';
$food['meat'][] = 'fish';
Multidimensional Arrays - Ex 5
● We know that PHP is awesome
● We know A LOT of people use PHP
● We’ve greeted the world of PHP
● We have seen how to get data from users
● We are absolute EXPERTS at Arrays
The Story So Far
Conditions
$name = 'Joe';
//$name = 'Bill the pony';
if($name == 'Joe'){
echo '<p>Hello Joe, welcome back</p>';
} else {
echo '<p>Hello ' . $name . '</p>';
}
Putting it together… Example 6
Foreach steps through each item.
You perform some action on each item.
foreach($fruit AS $key => $value){
echo '<li>' . $value . '</p>';
}
For Loops - Example 7
While loops perform the action while a
condition is met and then stops.
$fruit_count = count($fruit);
$f = 0;
while ($f < $fruit_count){
echo '<li>' . $fruit[$f] . '</li>';
$f++;
}
While Loops - Example 8
function getFruit(){
$fruit = array();
$fruit[] = 'apple';
$fruit[] = 'pear';
$fruit[] = 'orange';
$fruit[] = 'lemon';
$fruit[] = 'pineapple';
return $fruit;
}
FUNctions - Example 9
Using the previous getFruit function:
$fruit = getFruit();
$fruit is now an array created by the function
Using Functions - Example 9
● You can pass data into an array by adding
arguments
function getFruitOrMeat($fruit_or_meat){
…
}
$fruit_or_meat is data we are passing into
the getFruitOrMeat function
Function Arguments Example 10
The best PHP resources:
● phptherightway.com
● php.net
Online Learning:
● codecademy.com
● php.net/manual/en/getting-started.php
More Information

Mais conteúdo relacionado

Mais procurados

PHP an intro -1
PHP an intro -1PHP an intro -1
PHP an intro -1Kanchilug
 
Huong dan cai dat hadoop
Huong dan cai dat hadoopHuong dan cai dat hadoop
Huong dan cai dat hadoopQuỳnh Phan
 
Path::Tiny
Path::TinyPath::Tiny
Path::Tinywaniji
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with PuppetOlinData
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with PuppetWalter Heck
 
Hands on django part 1
Hands on django part 1Hands on django part 1
Hands on django part 1MicroPyramid .
 
Php tutorial handout
Php tutorial handoutPhp tutorial handout
Php tutorial handoutSBalan Balan
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part AKazuchika Sekiya
 
HTML Templates Using Clear Silver
HTML Templates Using Clear SilverHTML Templates Using Clear Silver
HTML Templates Using Clear SilverPaulWay
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and coPierre Joye
 
Fcontratos
FcontratosFcontratos
Fcontratoskarlloss
 
Client-side Storage 
Client-side Storage Client-side Storage 
Client-side Storage Tobias Wolf
 
Not Really PHP by the book
Not Really PHP by the bookNot Really PHP by the book
Not Really PHP by the bookRyan Kilfedder
 

Mais procurados (20)

PHP an intro -1
PHP an intro -1PHP an intro -1
PHP an intro -1
 
Huong dan cai dat hadoop
Huong dan cai dat hadoopHuong dan cai dat hadoop
Huong dan cai dat hadoop
 
Path::Tiny
Path::TinyPath::Tiny
Path::Tiny
 
Phphacku iitd
Phphacku iitdPhphacku iitd
Phphacku iitd
 
Hardcore PHP
Hardcore PHPHardcore PHP
Hardcore PHP
 
Php hacku
Php hackuPhp hacku
Php hacku
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
 
Hands on django part 1
Hands on django part 1Hands on django part 1
Hands on django part 1
 
Php tutorial handout
Php tutorial handoutPhp tutorial handout
Php tutorial handout
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part A
 
HTML Templates Using Clear Silver
HTML Templates Using Clear SilverHTML Templates Using Clear Silver
HTML Templates Using Clear Silver
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and co
 
Fcontratos
FcontratosFcontratos
Fcontratos
 
Client-side Storage 
Client-side Storage Client-side Storage 
Client-side Storage 
 
Clean Code Tips (Day 1 )
Clean Code Tips (Day 1 )Clean Code Tips (Day 1 )
Clean Code Tips (Day 1 )
 
Not Really PHP by the book
Not Really PHP by the bookNot Really PHP by the book
Not Really PHP by the book
 
Perl5i
Perl5iPerl5i
Perl5i
 
Php, mysq lpart1
Php, mysq lpart1Php, mysq lpart1
Php, mysq lpart1
 

Semelhante a Getting started with php

Semelhante a Getting started with php (20)

Php7 HHVM and co
Php7 HHVM and coPhp7 HHVM and co
Php7 HHVM and co
 
Lecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdfLecture2_IntroductionToPHP_Spring2023.pdf
Lecture2_IntroductionToPHP_Spring2023.pdf
 
Php7 hhvm and co
Php7 hhvm and coPhp7 hhvm and co
Php7 hhvm and co
 
Starting Out With PHP
Starting Out With PHPStarting Out With PHP
Starting Out With PHP
 
Laravel level 0 (introduction)
Laravel level 0 (introduction)Laravel level 0 (introduction)
Laravel level 0 (introduction)
 
PHP Jump Start
PHP Jump StartPHP Jump Start
PHP Jump Start
 
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
 
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
 
The new features of PHP 7
The new features of PHP 7The new features of PHP 7
The new features of PHP 7
 
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 mysql
Php mysqlPhp mysql
Php mysql
 
PHP BASIC PRESENTATION
PHP BASIC PRESENTATIONPHP BASIC PRESENTATION
PHP BASIC PRESENTATION
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
 
Php tutorialw3schools
Php tutorialw3schoolsPhp tutorialw3schools
Php tutorialw3schools
 
Php with my sql
Php with my sqlPhp with my sql
Php with my sql
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Php mysql training-in-mumbai
Php mysql training-in-mumbaiPhp mysql training-in-mumbai
Php mysql training-in-mumbai
 

Mais de Joe Ferguson

Modern infrastructure as code with ansible cake fest 2021
Modern infrastructure as code with ansible cake fest 2021Modern infrastructure as code with ansible cake fest 2021
Modern infrastructure as code with ansible cake fest 2021Joe Ferguson
 
Modern infrastructure as code with ansible PyTN
Modern infrastructure as code with ansible  PyTNModern infrastructure as code with ansible  PyTN
Modern infrastructure as code with ansible PyTNJoe Ferguson
 
Slim PHP when you don't need the kitchen sink
Slim PHP   when you don't need the kitchen sinkSlim PHP   when you don't need the kitchen sink
Slim PHP when you don't need the kitchen sinkJoe Ferguson
 
Throwing Laravel into your Legacy App™
Throwing Laravel into your Legacy App™Throwing Laravel into your Legacy App™
Throwing Laravel into your Legacy App™Joe Ferguson
 
DevSpace Conf 2017 - Making sense of the provisioning circus
DevSpace Conf 2017 - Making sense of the provisioning circusDevSpace Conf 2017 - Making sense of the provisioning circus
DevSpace Conf 2017 - Making sense of the provisioning circusJoe Ferguson
 
Release and-dependency-management memphis python
Release and-dependency-management memphis pythonRelease and-dependency-management memphis python
Release and-dependency-management memphis pythonJoe Ferguson
 
Composer at Scale, Release and Dependency Management
Composer at Scale, Release and Dependency ManagementComposer at Scale, Release and Dependency Management
Composer at Scale, Release and Dependency ManagementJoe Ferguson
 
Put an end to regression with codeception testing
Put an end to regression with codeception testingPut an end to regression with codeception testing
Put an end to regression with codeception testingJoe Ferguson
 
Midwest PHP 2017 DevOps For Small team
Midwest PHP 2017 DevOps For Small teamMidwest PHP 2017 DevOps For Small team
Midwest PHP 2017 DevOps For Small teamJoe Ferguson
 
All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$Joe Ferguson
 
Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:win Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:win Joe Ferguson
 
Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:winConsole Apps: php artisan forthe:win
Console Apps: php artisan forthe:winJoe Ferguson
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$Joe Ferguson
 
So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016Joe Ferguson
 
So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...Joe Ferguson
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionJoe Ferguson
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 Joe Ferguson
 
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Acceptance & Functional Testing with Codeception - SunshinePHP 2016Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Acceptance & Functional Testing with Codeception - SunshinePHP 2016Joe Ferguson
 
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialAdventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialJoe Ferguson
 
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
php[world] 2015 Laravel 5.1: From Homestead to the Cloudphp[world] 2015 Laravel 5.1: From Homestead to the Cloud
php[world] 2015 Laravel 5.1: From Homestead to the CloudJoe Ferguson
 

Mais de Joe Ferguson (20)

Modern infrastructure as code with ansible cake fest 2021
Modern infrastructure as code with ansible cake fest 2021Modern infrastructure as code with ansible cake fest 2021
Modern infrastructure as code with ansible cake fest 2021
 
Modern infrastructure as code with ansible PyTN
Modern infrastructure as code with ansible  PyTNModern infrastructure as code with ansible  PyTN
Modern infrastructure as code with ansible PyTN
 
Slim PHP when you don't need the kitchen sink
Slim PHP   when you don't need the kitchen sinkSlim PHP   when you don't need the kitchen sink
Slim PHP when you don't need the kitchen sink
 
Throwing Laravel into your Legacy App™
Throwing Laravel into your Legacy App™Throwing Laravel into your Legacy App™
Throwing Laravel into your Legacy App™
 
DevSpace Conf 2017 - Making sense of the provisioning circus
DevSpace Conf 2017 - Making sense of the provisioning circusDevSpace Conf 2017 - Making sense of the provisioning circus
DevSpace Conf 2017 - Making sense of the provisioning circus
 
Release and-dependency-management memphis python
Release and-dependency-management memphis pythonRelease and-dependency-management memphis python
Release and-dependency-management memphis python
 
Composer at Scale, Release and Dependency Management
Composer at Scale, Release and Dependency ManagementComposer at Scale, Release and Dependency Management
Composer at Scale, Release and Dependency Management
 
Put an end to regression with codeception testing
Put an end to regression with codeception testingPut an end to regression with codeception testing
Put an end to regression with codeception testing
 
Midwest PHP 2017 DevOps For Small team
Midwest PHP 2017 DevOps For Small teamMidwest PHP 2017 DevOps For Small team
Midwest PHP 2017 DevOps For Small team
 
All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$
 
Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:win Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:win
 
Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:winConsole Apps: php artisan forthe:win
Console Apps: php artisan forthe:win
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$
 
So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016
 
So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello Production
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5
 
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Acceptance & Functional Testing with Codeception - SunshinePHP 2016Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
 
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialAdventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
 
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
php[world] 2015 Laravel 5.1: From Homestead to the Cloudphp[world] 2015 Laravel 5.1: From Homestead to the Cloud
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
 

Último

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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...
 
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...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Getting started with php

  • 2. Joe Ferguson - joe@joeferguson.me Professionally ● Web Developer at RocketFuel ● PHP / LAMP Focused Semi Professional ● Co-Organizer for MemphisPHP.org ● MidsouthMakers - Hackerspace Leader ● HACKmemphis.com Organizer Who is this guy?
  • 3. It’s a recursive anagram… PHP: Hypertext Preprocessor is a widely used, general- purpose scripting language that was originally designed for web development to produce dynamic web pages What is PHP?
  • 4. ● Widespread Availability ○ PHP is now installed on more than 244 million websites and 2.1 million web servers (Source: Wikipedia) ● Ease of use. ○ Extremely simple for newcomers ○ Advanced features for professional programmers ○ Looslely typed ● Great Community Support ● Many corporations throwing support behind PHP projects Why use PHP?
  • 5. Who uses it? What runs on PHP? ...and many, MANY others
  • 6. <html> <head> <title>Example 1 - Getting Started with PHP<</title> </head> <body> <?php echo '<p>Hello World</p>'; ?> </body> </html> Jumping into PHP - Example 1
  • 7. You can add any content to a PHP file. Anything not between PHP tags is ignored by PHP. Using echo, you can print from PHP. As example 1 shows, even PHP. Example 1 - Basic HTML + PHP
  • 8. PHP is very easy to pick up and run with. This is one of the main reasons it is so widespread. Looks easy right?
  • 9. $_GET Variables come from the URL Bad: <?php $name = $_GET['name']; ?> NEVER trust data from your users! Good: <?php if(isset($_GET['name'])){ $name = filter_var($_GET['name'],FILTER_SANITIZE_STRING); } ?> Getting Data from the User
  • 10. So what is happening? ● First we check if the name exists by looking at $_GET[‘name’] ○ if(isset($_GET['name'])){ ● If it does exist, we pass it to a function to sanitize the input and set the results equal to $name ○ $name = filter_var($_GET['name'],FILTER_SANITIZE_STRING); Getting Data from the User
  • 11. ● isset ● empty ● filter_var ● arrays ● strings ● omgwtf! The best PHP resources: ● phptherightway.com ● php.net I can’t keep track of all this!
  • 12. PHP Specification Request (PSR) The Framework Interop Group: ● PSR-0 ● PSR-1 ● PSR-2 Other Styles: ● PEAR Coding Standards ● Zend Coding Standards OMG your { are on the wrong line!
  • 13. There are subtle differences among the PSR coding styles approved by the FIG. If you’re wanting to maximize your reusability: pick a PSR similar to the code you are working with. Most projects won’t take code if it doesn’t match the style they have adopted. Why so many? What do I use?
  • 14. Strings ● echo ‘PHP is my favorite language’; ● $variable = ‘PHP is amazing’; ● echo "PHP! you'll be astonished"; ● echo 'PHP! you'll be astonished'; Concatenation ● echo "Hello, " . $prefix . " " . $name; Single quote strings do not get parsed. Double quote strings get parsed. Are slower than single quote strings because of this. Before we get too complicated:
  • 15. Simple Arrays: <?php $fruit = array(); $fruit[] = 'apple'; $fruit[] = 'pear'; $fruit[] = 'orange'; $fruit[] = 'lemon'; $fruit[] = 'pineapple'; ?> Arrays - associating values to keys
  • 16. $food = array(); $food['fruit'] = array(); $food['fruit'][] = 'apple'; $food['fruit'][] = 'pear'; $food['fruit'][] = 'orange'; $food['fruit'][] = 'lemon'; $food['fruit'][] = 'pineapple'; $food['meat'] = array(); $food['meat'][] = 'bacon'; $food['meat'][] = 'steak'; $food['meat'][] = 'chicken'; $food['meat'][] = 'fish'; Multidimensional Arrays - Ex 5
  • 17. ● We know that PHP is awesome ● We know A LOT of people use PHP ● We’ve greeted the world of PHP ● We have seen how to get data from users ● We are absolute EXPERTS at Arrays The Story So Far
  • 18. Conditions $name = 'Joe'; //$name = 'Bill the pony'; if($name == 'Joe'){ echo '<p>Hello Joe, welcome back</p>'; } else { echo '<p>Hello ' . $name . '</p>'; } Putting it together… Example 6
  • 19. Foreach steps through each item. You perform some action on each item. foreach($fruit AS $key => $value){ echo '<li>' . $value . '</p>'; } For Loops - Example 7
  • 20. While loops perform the action while a condition is met and then stops. $fruit_count = count($fruit); $f = 0; while ($f < $fruit_count){ echo '<li>' . $fruit[$f] . '</li>'; $f++; } While Loops - Example 8
  • 21. function getFruit(){ $fruit = array(); $fruit[] = 'apple'; $fruit[] = 'pear'; $fruit[] = 'orange'; $fruit[] = 'lemon'; $fruit[] = 'pineapple'; return $fruit; } FUNctions - Example 9
  • 22. Using the previous getFruit function: $fruit = getFruit(); $fruit is now an array created by the function Using Functions - Example 9
  • 23. ● You can pass data into an array by adding arguments function getFruitOrMeat($fruit_or_meat){ … } $fruit_or_meat is data we are passing into the getFruitOrMeat function Function Arguments Example 10
  • 24. The best PHP resources: ● phptherightway.com ● php.net Online Learning: ● codecademy.com ● php.net/manual/en/getting-started.php More Information