SlideShare a Scribd company logo
Glory with PHP
  Anshu Prateek
PHP
HyperText
Processor
Agenda
•   The basics
•   Enough PHP to handle simple request
•   How to talk to backend data store using PHP
•   How to parse/generate XML/JSON in PHP
What is it..?!
•   What is PHP?!
•   RasmusLerdorf – 1995
•   Compile or interpret?
•   CLI?
Pre-requisites



    LAMP/WAMP/MAMP
L/W/M – Linux/Windows/Mac
        A – Apache
         M – Mysql
          P - PHP
About me.. Err.. PHP

    Latest Version : 5.4.0 (released on march 01, 2012)
Presently hosted on github: https://github.com/php/php-src
      Written in C, you can write your own modules!
The basics
• Starts with <?php
• <? Also accepted but recommended not to use
  due to xml usage
• Closing ?> is not mandatory unless code
  structure requires closure.
• Infact if possible, do not use closing ?> , helps
  avoid “header already sent” errors.
• Double quotes allow variable substitution, single
  quotes don‟t.
• Variables start with $
Helooo world!
• <?php                  • php -r '$greet =
• $greet = “hello”;        "hello";echo "$greet
• Echo $greet.‟world‟;     world";'
Ways to put long text
• <?php
• $variable = „the long long long copied wikipedia
  text”;
  ?>
<html>
…
<body>
<?php
echo $text;
?>
</body>
Or use HEREDOC
•   <?php
•   $name = „doctor who‟;
•   $html=<<<HTML
•   this is some html
•   And some more html
•   And only html!
•   And I can use $name „s alien powers as well!
•   HTML;
•   echo $html;
Strings
• http://us2.php.net/manual/en/ref.strings.php
• The various inputs and outputs need to be
  formatted.
  Various functions.
string substr ( string $string , int $start [, int
  $length ] )
• string strstr ( string $haystack , mixed $needle [,
  bool $before_needle = false ] )
• And many more…
Arrays
• $array = array(
     "foo" => "bar",
     42 => 24,
     "multi" => array(
        "dimensional" => array(
          "array" => "foo"
        )
     )
  );
• var_dump($array["foo"]);
  var_dump($array[42]);
  var_dump($array["multi"]["dimensional"]["array
  "]);
Arrays..
• http://www.php.net/manual/en/function.array.ph
  p
Functions
• Function
             <?php
             function renderList($array){
               if( sizeof($array) > 0 ){
                 echo '<ul>';
             foreach( $array as $key => $item ){
                   echo '<li>' . $key . ':' . $item . '</li>';
                 }
                 echo '</ul>';
               }
             }
             $lampstack = array(
               'Operating System' => 'Linux',
               'Server' => 'Apache',
               'Database' => 'MySQL',
               'Language' => 'PHP'
             );
             renderList($lampstack);
             ?>
Talking with your page
•   $_GET
•   Example.com/?query=hacku
•   $query = $_GET[„query‟]
•   $_POST
•   <form id=“iitm>
•   <input type=“text” name=“userid” />
•   <submit>
•   </form>

$id = $_POST[„userid‟];
$_COOKIES;
Fetching data from the web..
• BOSS
• Uses OAUTH
Adding it all up together..
Pictionary!
1)Getting the user provided text.
2) Remove the blacklist words.
3) Get image for the rest of the words.

Show me the code..!
https://github.com/anshprat/hacku

More Related Content

What's hot

PHP: The easiest language to learn.
PHP: The easiest language to learn.PHP: The easiest language to learn.
PHP: The easiest language to learn.
Binny V A
 
Perl Basics for Pentesters Part 1
Perl Basics for Pentesters Part 1Perl Basics for Pentesters Part 1
Perl Basics for Pentesters Part 1
n|u - The Open Security Community
 
Intro to PHP
Intro to PHPIntro to PHP
Intro to PHP
Sandy Smith
 
Php hacku
Php hackuPhp hacku
Ruby 2.0
Ruby 2.0Ruby 2.0
Ruby 2.0
Uģis Ozols
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)
Kris Wallsmith
 
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Balázs Tatár
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Kris Wallsmith
 
Let's write secure Drupal code! - Drupal Camp Poland 2019
Let's write secure Drupal code! - Drupal Camp Poland 2019Let's write secure Drupal code! - Drupal Camp Poland 2019
Let's write secure Drupal code! - Drupal Camp Poland 2019
Balázs Tatár
 
Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019
Balázs Tatár
 
DBIx::Skinnyと仲間たち
DBIx::Skinnyと仲間たちDBIx::Skinnyと仲間たち
DBIx::Skinnyと仲間たち
Ryo Miyake
 
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Balázs Tatár
 
Migrating to Puppet 4.0
Migrating to Puppet 4.0Migrating to Puppet 4.0
Migrating to Puppet 4.0
Puppet
 
Writing Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterWriting Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterCodeIgniter Conference
 
FizzBuzzではじめるテスト
FizzBuzzではじめるテストFizzBuzzではじめるテスト
FizzBuzzではじめるテスト
Masashi Shinbara
 
Presentation on php string function part-2
Presentation on php string function part-2Presentation on php string function part-2
Presentation on php string function part-2
Mysoftheaven (BD) Ltd.
 

What's hot (20)

PHP: The easiest language to learn.
PHP: The easiest language to learn.PHP: The easiest language to learn.
PHP: The easiest language to learn.
 
Perl Basics for Pentesters Part 1
Perl Basics for Pentesters Part 1Perl Basics for Pentesters Part 1
Perl Basics for Pentesters Part 1
 
Intro to PHP
Intro to PHPIntro to PHP
Intro to PHP
 
Perl5i
Perl5iPerl5i
Perl5i
 
Php hacku
Php hackuPhp hacku
Php hacku
 
Perl basics for pentesters part 2
Perl basics for pentesters part 2Perl basics for pentesters part 2
Perl basics for pentesters part 2
 
Ruby 2.0
Ruby 2.0Ruby 2.0
Ruby 2.0
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)
 
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Let's write secure Drupal code! - Drupal Camp Poland 2019
Let's write secure Drupal code! - Drupal Camp Poland 2019Let's write secure Drupal code! - Drupal Camp Poland 2019
Let's write secure Drupal code! - Drupal Camp Poland 2019
 
Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019
 
DBIx::Skinnyと仲間たち
DBIx::Skinnyと仲間たちDBIx::Skinnyと仲間たち
DBIx::Skinnyと仲間たち
 
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019
 
Migrating to Puppet 4.0
Migrating to Puppet 4.0Migrating to Puppet 4.0
Migrating to Puppet 4.0
 
Writing Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterWriting Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniter
 
FizzBuzzではじめるテスト
FizzBuzzではじめるテストFizzBuzzではじめるテスト
FizzBuzzではじめるテスト
 
My shell
My shellMy shell
My shell
 
Presentation on php string function part-2
Presentation on php string function part-2Presentation on php string function part-2
Presentation on php string function part-2
 

Viewers also liked

20 Shades of Blue
20 Shades of Blue20 Shades of Blue
20 Shades of Blue
Anshu Prateek
 
what/why/how of IPv6 || 2002:3239:43c3::1
what/why/how of IPv6 || 2002:3239:43c3::1what/why/how of IPv6 || 2002:3239:43c3::1
what/why/how of IPv6 || 2002:3239:43c3::1
Anshu Prateek
 
M-Commerce - Social-Loco Slides - Dr. Phil Hendrix, immr
M-Commerce - Social-Loco Slides - Dr. Phil Hendrix, immrM-Commerce - Social-Loco Slides - Dr. Phil Hendrix, immr
M-Commerce - Social-Loco Slides - Dr. Phil Hendrix, immr
Phil Hendrix
 
Drive Revenue and Loyalty by Engaging Mobile and Social Consumers
Drive Revenue and Loyalty by Engaging Mobile and Social ConsumersDrive Revenue and Loyalty by Engaging Mobile and Social Consumers
Drive Revenue and Loyalty by Engaging Mobile and Social Consumers
Phil Hendrix
 
Hacking up location aware apps
Hacking up location aware appsHacking up location aware apps
Hacking up location aware appsAnshu Prateek
 
Yql hacku iitd_2012
Yql hacku iitd_2012Yql hacku iitd_2012
Yql hacku iitd_2012
Anshu Prateek
 
Tablet Market Outlook - April 2011 - Dr. Phil Hendrix, immr
Tablet Market Outlook - April 2011 - Dr. Phil Hendrix, immrTablet Market Outlook - April 2011 - Dr. Phil Hendrix, immr
Tablet Market Outlook - April 2011 - Dr. Phil Hendrix, immr
Phil Hendrix
 

Viewers also liked (7)

20 Shades of Blue
20 Shades of Blue20 Shades of Blue
20 Shades of Blue
 
what/why/how of IPv6 || 2002:3239:43c3::1
what/why/how of IPv6 || 2002:3239:43c3::1what/why/how of IPv6 || 2002:3239:43c3::1
what/why/how of IPv6 || 2002:3239:43c3::1
 
M-Commerce - Social-Loco Slides - Dr. Phil Hendrix, immr
M-Commerce - Social-Loco Slides - Dr. Phil Hendrix, immrM-Commerce - Social-Loco Slides - Dr. Phil Hendrix, immr
M-Commerce - Social-Loco Slides - Dr. Phil Hendrix, immr
 
Drive Revenue and Loyalty by Engaging Mobile and Social Consumers
Drive Revenue and Loyalty by Engaging Mobile and Social ConsumersDrive Revenue and Loyalty by Engaging Mobile and Social Consumers
Drive Revenue and Loyalty by Engaging Mobile and Social Consumers
 
Hacking up location aware apps
Hacking up location aware appsHacking up location aware apps
Hacking up location aware apps
 
Yql hacku iitd_2012
Yql hacku iitd_2012Yql hacku iitd_2012
Yql hacku iitd_2012
 
Tablet Market Outlook - April 2011 - Dr. Phil Hendrix, immr
Tablet Market Outlook - April 2011 - Dr. Phil Hendrix, immrTablet Market Outlook - April 2011 - Dr. Phil Hendrix, immr
Tablet Market Outlook - April 2011 - Dr. Phil Hendrix, immr
 

Similar to PHP Basics and Demo HackU

MIND sweeping introduction to PHP
MIND sweeping introduction to PHPMIND sweeping introduction to PHP
MIND sweeping introduction to PHPBUDNET
 
Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010
Michelangelo van Dam
 
php fundamental
php fundamentalphp fundamental
php fundamental
zalatarunk
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of phppooja bhandari
 
PHP
PHPPHP
php (Hypertext Preprocessor)
php (Hypertext Preprocessor)php (Hypertext Preprocessor)
php (Hypertext Preprocessor)
Chandan Das
 
Starting Out With PHP
Starting Out With PHPStarting Out With PHP
Starting Out With PHP
Mark Niebergall
 
Prersentation
PrersentationPrersentation
Prersentation
Ashwin Deora
 
Php classes in mumbai
Php classes in mumbaiPhp classes in mumbai
Php classes in mumbai
Vibrant Technologies & Computers
 
Php training100%placement-in-mumbai
Php training100%placement-in-mumbaiPhp training100%placement-in-mumbai
Php training100%placement-in-mumbai
vibrantuser
 
Php basic for vit university
Php basic for vit universityPhp basic for vit university
Php basic for vit university
Mandakini Kumari
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHPNat Weerawan
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course Deck
rICh morrow
 
sumana_PHP_mysql_IIT_BOMBAY_2013
sumana_PHP_mysql_IIT_BOMBAY_2013sumana_PHP_mysql_IIT_BOMBAY_2013
sumana_PHP_mysql_IIT_BOMBAY_2013Sumana Hariharan
 

Similar to PHP Basics and Demo HackU (20)

MIND sweeping introduction to PHP
MIND sweeping introduction to PHPMIND sweeping introduction to PHP
MIND sweeping introduction to PHP
 
Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010
 
php fundamental
php fundamentalphp fundamental
php fundamental
 
php
phpphp
php
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
 
PHP
PHPPHP
PHP
 
php (Hypertext Preprocessor)
php (Hypertext Preprocessor)php (Hypertext Preprocessor)
php (Hypertext Preprocessor)
 
Starting Out With PHP
Starting Out With PHPStarting Out With PHP
Starting Out With PHP
 
rtwerewr
rtwerewrrtwerewr
rtwerewr
 
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
 
Prersentation
PrersentationPrersentation
Prersentation
 
05php
05php05php
05php
 
05php
05php05php
05php
 
05php
05php05php
05php
 
Php classes in mumbai
Php classes in mumbaiPhp classes in mumbai
Php classes in mumbai
 
Php training100%placement-in-mumbai
Php training100%placement-in-mumbaiPhp training100%placement-in-mumbai
Php training100%placement-in-mumbai
 
Php basic for vit university
Php basic for vit universityPhp basic for vit university
Php basic for vit university
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course Deck
 
sumana_PHP_mysql_IIT_BOMBAY_2013
sumana_PHP_mysql_IIT_BOMBAY_2013sumana_PHP_mysql_IIT_BOMBAY_2013
sumana_PHP_mysql_IIT_BOMBAY_2013
 

Recently uploaded

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 

Recently uploaded (20)

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 

PHP Basics and Demo HackU

  • 1. Glory with PHP Anshu Prateek
  • 3. Agenda • The basics • Enough PHP to handle simple request • How to talk to backend data store using PHP • How to parse/generate XML/JSON in PHP
  • 4. What is it..?! • What is PHP?! • RasmusLerdorf – 1995 • Compile or interpret? • CLI?
  • 5. Pre-requisites LAMP/WAMP/MAMP L/W/M – Linux/Windows/Mac A – Apache M – Mysql P - PHP
  • 6. About me.. Err.. PHP Latest Version : 5.4.0 (released on march 01, 2012) Presently hosted on github: https://github.com/php/php-src Written in C, you can write your own modules!
  • 7. The basics • Starts with <?php • <? Also accepted but recommended not to use due to xml usage • Closing ?> is not mandatory unless code structure requires closure. • Infact if possible, do not use closing ?> , helps avoid “header already sent” errors. • Double quotes allow variable substitution, single quotes don‟t. • Variables start with $
  • 8. Helooo world! • <?php • php -r '$greet = • $greet = “hello”; "hello";echo "$greet • Echo $greet.‟world‟; world";'
  • 9. Ways to put long text • <?php • $variable = „the long long long copied wikipedia text”; ?> <html> … <body> <?php echo $text; ?> </body>
  • 10. Or use HEREDOC • <?php • $name = „doctor who‟; • $html=<<<HTML • this is some html • And some more html • And only html! • And I can use $name „s alien powers as well! • HTML; • echo $html;
  • 11. Strings • http://us2.php.net/manual/en/ref.strings.php • The various inputs and outputs need to be formatted. Various functions. string substr ( string $string , int $start [, int $length ] ) • string strstr ( string $haystack , mixed $needle [, bool $before_needle = false ] ) • And many more…
  • 12. Arrays • $array = array( "foo" => "bar", 42 => 24, "multi" => array( "dimensional" => array( "array" => "foo" ) ) ); • var_dump($array["foo"]); var_dump($array[42]); var_dump($array["multi"]["dimensional"]["array "]);
  • 14. Functions • Function <?php function renderList($array){ if( sizeof($array) > 0 ){ echo '<ul>'; foreach( $array as $key => $item ){ echo '<li>' . $key . ':' . $item . '</li>'; } echo '</ul>'; } } $lampstack = array( 'Operating System' => 'Linux', 'Server' => 'Apache', 'Database' => 'MySQL', 'Language' => 'PHP' ); renderList($lampstack); ?>
  • 15. Talking with your page • $_GET • Example.com/?query=hacku • $query = $_GET[„query‟] • $_POST • <form id=“iitm> • <input type=“text” name=“userid” /> • <submit> • </form> $id = $_POST[„userid‟]; $_COOKIES;
  • 16. Fetching data from the web.. • BOSS • Uses OAUTH
  • 17. Adding it all up together.. Pictionary! 1)Getting the user provided text. 2) Remove the blacklist words. 3) Get image for the rest of the words. Show me the code..! https://github.com/anshprat/hacku

Editor's Notes

  1. What is PHP?!PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.Code is interpreted by a Web server with a PHP processor module which generates the resulting Web page.Includes a command-line interface capability and can be used in standalone graphical applications