SlideShare uma empresa Scribd logo
1 de 42
PHP + My SQL
What is PHP?

   PHP stands for PHP: Hypertext Preprocessor
   PHP is a server-side scripting language, like
    ASP
   PHP scripts are executed on the server
   PHP supports many databases (MySQL,
    Informix, Oracle, Sybase, Solid, PostgreSQL,
    Generic ODBC, etc.)
   PHP is an open source software
   PHP is free to download and use
What is a PHP File?

 PHP  files can contain text, HTML tags and
  scripts
 PHP files are returned to the browser as
  plain HTML
 PHP files have a file extension of ".php",
  ".php3", or ".phtml"
What is MySQL?

 MySQL  is a database server
 MySQL is ideal for both small and large
  applications
 MySQL supports standard SQL
 MySQL compiles on a number of
  platforms
 MySQL is free to download and use
PHP + MySQL

 PHP combined with MySQL are cross-
 platform (you can develop in Windows
 and serve on a Unix platform)
Why PHP?

 PHP  runs on different platforms (Windows,
  Linux, Unix, etc.)
 PHP is compatible with almost all servers
  used today (Apache, IIS, etc.)
 PHP is FREE to download from the official
  PHP resource: www.php.net
 PHP is easy to learn and runs efficiently on
  the server side
Start With PHP
 To start with PHP you will need to install
  PHP 5.0 or higher.
 In addition to PHP you should install MY
  SQL as database
 You can download PHP from
How the PHP works
OOP
 What   Is an Object?
    An object is a software bundle of related
     state and behavior. Software objects are
     often used to model the real-world objects
     that you find in everyday life.
 What   is a class?
    Class is a collection of a objects with
     common properties.
Object
   Software objects are conceptually similar to real-
    world objects: they too consist of state and related
    behavior. An object stores its state in fields
    (variables in some programming languages) and
    exposes its behavior through methods (functions in
    some programming languages). Methods operate
    on an object's internal state and serve as the
    primary mechanism for object-to-object
    communication. Hiding internal state and
    requiring all interaction to be performed through
    an object's methods is known as data
    encapsulation — a fundamental principle of
    object-oriented programming.
Object
   Objects are key to understanding object-oriented
    technology. Look around right now and you'll find
    many examples of real-world objects: your dog, your
    desk, your television set, your bicycle. Real-world
    objects share two characteristics: They all have state
    and behavior.
        Dogs have state<attributes> (name, color, breed,
        hungry) and behavior (barking, fetching, wagging tail).
       Bicycles also have state (current gear, current pedal
        cadence, current speed) and behavior (changing gear,
        changing pedal cadence, applying brakes). Identifying
        the state and behavior for real-world objects is a great
        way to begin thinking in terms of object-oriented
        programming.
Class

   In the real world, you'll often find many
    individual objects all of the same kind. There
    may be thousands of other bicycles in
    existence, all of the same make and model.
    Each bicycle was built from the same set of
    blueprints and therefore contains the same
    components. In object-oriented terms, we say
    that your bicycle is an instance of the class of
    objects known as bicycles. A class is the
    blueprint from which individual objects are
    created.
What Is Inheritance?
   Different kinds of objects often have a certain amount in common
    with each other. Mountain bikes, road bikes, and tandem bikes,

    for example, all share the characteristics of bicycles (current
    speed, current pedal cadence, current gear). Yet each also
    defines additional features that make them different: tandem
    bicycles have two seats and two sets of handlebars; road bikes
    have drop handlebars; some mountain bikes have an additional
    chain ring, giving them a lower gear ratio.

    Object-oriented programming allows classes to inherit commonly
    used state and behavior from other classes. In this example, Bicycle
    now becomes the superclass of MountainBike, RoadBike, and
    TandemBike. In the Java programming language, each class is
    allowed to have one direct superclass, and each superclass has
    the potential for an unlimited number of subclasses:
Inheritance
Interface
 Interface makes the relationship between
  classes and functionality to those classes
  implement easier to understand and to
  design
 A interface is a collection of methods that
  indicate a class has some behavior in
  addition to what in inherits from supper
  class;
Packages
 Packages   are use to grouping related
  classes and interfaces
 Java has many packages than make our
  work lot easier
 For take advantages of other packages
  you must import them
Basic PHP Syntax

A PHP scripting block always starts with
 <?php and ends with ?>. A PHP scripting
 block can be placed anywhere in the
 document.
 <html>
 <body>

 <?php
 echo "Hello World";
 ?>

 </body>
 </html>
   <html>
    <body>
    <?php
    //This is a comment
    /*
    This is
    a comment
    block
    */
    ?>
    </body>
    </html>
Variables in PHP

 Variables   in PHP
 Variables are used for storing values, like
  text strings, numbers or arrays.
 When a variable is declared, it can be
  used over and over again in your script.
 All variables in PHP start with a $ sign
  symbol.
Keywords
Variable ex
 $var_name   = value;
 <?php
  $txt="Hello World!";
  $x=16;
  ?>
 <?php
  $txt="Hello World";
  echo $txt;
  ?>
Variable Ex
 <?php
 $txt1="Hello World!";
 $txt2="What a nice day!";
 echo $txt1 . " " . $txt2;
 ?>
Strlen & strpos

 <?php
  echo strlen("Hello world!");
  ?>
 <?php
  echo strpos("Hello world!","world");
  ?>
Array
 The array functions allow you to
  manipulate arrays.
 PHP supports both simple and multi-
  dimensional arrays. There are also specific
  functions for populating arrays from
  database queries.

 Syntax
     array(key => value)
Array
   <?php
    $a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse");
       print_r($a);
    ?>
 <?php
    $arr = array("foo" => "bar", 12 => true);

        echo $arr["foo"];
        echo $arr[12];
?>
Array
 <?php
 $arr = array(“Horana”,”Colombo”,”Nuwar
            aeliya”,”Kandi”);

     echo $arr[1];
     echo $arr[4];
?>
PHP Operators
Arithmetic Operators


Operator      Description                    Example   Result
+             Addition                       x=2       4
                                             x+2
-             Subtraction                    x=2       3
                                             5-x
*             Multiplication                 x=4       20
                                             x*5
/             Division                       15/5      3
                                             5/2       2.5
%             Modulus (division remainder)   5%2       1
                                             10%8      2
                                             10%2      0
++            Increment                      x=5       x=6
                                             x++
--            Decrement                      x=5       x=4
                                             x--
Assignment Operators

Operator   Example   Is The Same As

=          x=y       x=y

+=         x+=y      x=x+y

-=         x-=y      x=x-y

*=         x*=y      x=x*y

/=         x/=y      x=x/y

.=         x.=y      x=x.y

%=         x%=y      x=x%y
Comparison operators
Operator   Description                   Example


==         is equal to                   5==8 returns false


!=         is not equal                  5!=8 returns true


<>         is not equal                  5<>8 returns true


>          is greater than               5>8 returns false


<          is less than                  5<8 returns true


>=         is greater than or equal to   5>=8 returns false


<=         is less than or equal to      5<=8 returns true
Logical Operators

Operator   Description   Example
&&         and           x=6
                         y=3

                         (x < 10 && y > 1) returns true
||         or            x=6
                         y=3

                         (x==5 || y==5) returns false
!          not           x=6
                         y=3

                         !(x==y) returns true
Flow Control
 IFelse
 Switch
 While
 Do while
 For
IF else
IF else Ex1
 <?php
 $n1 = 50;
 if(n1>=50){
      echo “Pass”;
 }else{
      echo “faille”
 }
 ?>
Switch
  <?php
$i = 281;

switch ($i) {
  case “281":
     echo “Thalgahavila Road";
     break;
  case “315":
     echo “Meeme Road";
     break;
  case “120":
     echo “Colombo Road";
     break;
}
?>
While
While ex
 <?php
     $i=0;
     while ($i<5){
     echo $i." "."AuD©"."<br/>";
     $i++;
     }
?>
Do While
 <?php
    $i=0;
    do{
    echo $i." "."AuD©"."<br/>";
    $i++;
    }while ($i<5)

    ?>
For
For
 <?php
       for($i=0;$i<5;$i++){
       echo $i." "."AuD©"."<br/>";
}

 ?>
For each
 <?php
$x=array("Ashen","Upendra","Disanayaka");
foreach($x as $value){
echo $value." ".".......AuD©.........";
}
 ?>

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHP
 
Your code sucks, let's fix it
Your code sucks, let's fix itYour code sucks, let's fix it
Your code sucks, let's fix it
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
Sorting arrays in PHP
Sorting arrays in PHPSorting arrays in PHP
Sorting arrays in PHP
 
Arrays in PHP
Arrays in PHPArrays in PHP
Arrays in PHP
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
 
Php Using Arrays
Php Using ArraysPhp Using Arrays
Php Using Arrays
 
Class 5 - PHP Strings
Class 5 - PHP StringsClass 5 - PHP Strings
Class 5 - PHP Strings
 
Your code sucks, let's fix it! - php|tek13
Your code sucks, let's fix it! - php|tek13Your code sucks, let's fix it! - php|tek13
Your code sucks, let's fix it! - php|tek13
 
Arrays in PHP
Arrays in PHPArrays in PHP
Arrays in PHP
 
Zend Certification Preparation Tutorial
Zend Certification Preparation TutorialZend Certification Preparation Tutorial
Zend Certification Preparation Tutorial
 
PHP Unit 4 arrays
PHP Unit 4 arraysPHP Unit 4 arrays
PHP Unit 4 arrays
 
Php & my sql
Php & my sqlPhp & my sql
Php & my sql
 
PHP variables
PHP  variablesPHP  variables
PHP variables
 
Making Sense of Twig
Making Sense of TwigMaking Sense of Twig
Making Sense of Twig
 
Web app development_php_04
Web app development_php_04Web app development_php_04
Web app development_php_04
 
PHP - Introduction to PHP
PHP -  Introduction to PHPPHP -  Introduction to PHP
PHP - Introduction to PHP
 
GDI Seattle - Intro to JavaScript Class 1
GDI Seattle - Intro to JavaScript Class 1GDI Seattle - Intro to JavaScript Class 1
GDI Seattle - Intro to JavaScript Class 1
 
Php array
Php arrayPhp array
Php array
 
Round PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallyRound PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing Functionally
 

Destaque (6)

Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessions
 
2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
 
Oops in PHP
Oops in PHPOops in PHP
Oops in PHP
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
PHP Classes and OOPS Concept
PHP Classes and OOPS ConceptPHP Classes and OOPS Concept
PHP Classes and OOPS Concept
 

Semelhante a PHP+MySQL Guide for Beginners in 38 Characters

Java script questions
Java script questionsJava script questions
Java script questionsSrikanth
 
OpenGurukul : Language : PHP
OpenGurukul : Language : PHPOpenGurukul : Language : PHP
OpenGurukul : Language : PHPOpen Gurukul
 
Php basic for vit university
Php basic for vit universityPhp basic for vit university
Php basic for vit universityMandakini Kumari
 
Php Tutorial
Php TutorialPhp Tutorial
Php TutorialSridhar P
 
Unit-1 PHP Basic1 of the understanding of php.pptx
Unit-1 PHP Basic1 of the understanding of php.pptxUnit-1 PHP Basic1 of the understanding of php.pptx
Unit-1 PHP Basic1 of the understanding of php.pptxAatifKhan84
 
Learn PHP Basics
Learn PHP Basics Learn PHP Basics
Learn PHP Basics McSoftsis
 
Php using variables-operators
Php using variables-operatorsPhp using variables-operators
Php using variables-operatorsKhem Puthea
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Gheyath M. Othman
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPrinceGuru MS
 
Synapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on phpSynapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on phpSynapseindiaComplaints
 
Synapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on phpSynapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on phpSynapseindiaComplaints
 
Expressions and Operators.pptx
Expressions and Operators.pptxExpressions and Operators.pptx
Expressions and Operators.pptxJapneet9
 
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdfIT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdfpkaviya
 
FYBSC IT Web Programming Unit IV PHP and MySQL
FYBSC IT Web Programming Unit IV  PHP and MySQLFYBSC IT Web Programming Unit IV  PHP and MySQL
FYBSC IT Web Programming Unit IV PHP and MySQLArti Parab Academics
 

Semelhante a PHP+MySQL Guide for Beginners in 38 Characters (20)

Php
PhpPhp
Php
 
Java script questions
Java script questionsJava script questions
Java script questions
 
Google maps
Google mapsGoogle maps
Google maps
 
OpenGurukul : Language : PHP
OpenGurukul : Language : PHPOpenGurukul : Language : PHP
OpenGurukul : Language : PHP
 
Php basic for vit university
Php basic for vit universityPhp basic for vit university
Php basic for vit university
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Unit-1 PHP Basic1 of the understanding of php.pptx
Unit-1 PHP Basic1 of the understanding of php.pptxUnit-1 PHP Basic1 of the understanding of php.pptx
Unit-1 PHP Basic1 of the understanding of php.pptx
 
Learn PHP Basics
Learn PHP Basics Learn PHP Basics
Learn PHP Basics
 
PHP PPT FILE
PHP PPT FILEPHP PPT FILE
PHP PPT FILE
 
PHP-Part1
PHP-Part1PHP-Part1
PHP-Part1
 
Php using variables-operators
Php using variables-operatorsPhp using variables-operators
Php using variables-operators
 
Php introduction
Php introductionPhp introduction
Php introduction
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1
 
Training on php by cyber security infotech (csi)
Training on  php by cyber security infotech (csi)Training on  php by cyber security infotech (csi)
Training on php by cyber security infotech (csi)
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_master
 
Synapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on phpSynapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on php
 
Synapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on phpSynapseindia reviews sharing intro on php
Synapseindia reviews sharing intro on php
 
Expressions and Operators.pptx
Expressions and Operators.pptxExpressions and Operators.pptx
Expressions and Operators.pptx
 
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdfIT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
 
FYBSC IT Web Programming Unit IV PHP and MySQL
FYBSC IT Web Programming Unit IV  PHP and MySQLFYBSC IT Web Programming Unit IV  PHP and MySQL
FYBSC IT Web Programming Unit IV PHP and MySQL
 

Último

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Último (20)

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

PHP+MySQL Guide for Beginners in 38 Characters

  • 1. PHP + My SQL
  • 2.
  • 3. What is PHP?  PHP stands for PHP: Hypertext Preprocessor  PHP is a server-side scripting language, like ASP  PHP scripts are executed on the server  PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)  PHP is an open source software  PHP is free to download and use
  • 4. What is a PHP File?  PHP files can contain text, HTML tags and scripts  PHP files are returned to the browser as plain HTML  PHP files have a file extension of ".php", ".php3", or ".phtml"
  • 5. What is MySQL?  MySQL is a database server  MySQL is ideal for both small and large applications  MySQL supports standard SQL  MySQL compiles on a number of platforms  MySQL is free to download and use
  • 6. PHP + MySQL  PHP combined with MySQL are cross- platform (you can develop in Windows and serve on a Unix platform)
  • 7. Why PHP?  PHP runs on different platforms (Windows, Linux, Unix, etc.)  PHP is compatible with almost all servers used today (Apache, IIS, etc.)  PHP is FREE to download from the official PHP resource: www.php.net  PHP is easy to learn and runs efficiently on the server side
  • 8. Start With PHP  To start with PHP you will need to install PHP 5.0 or higher.  In addition to PHP you should install MY SQL as database  You can download PHP from
  • 9. How the PHP works
  • 10. OOP  What Is an Object?  An object is a software bundle of related state and behavior. Software objects are often used to model the real-world objects that you find in everyday life.  What is a class?  Class is a collection of a objects with common properties.
  • 11. Object  Software objects are conceptually similar to real- world objects: they too consist of state and related behavior. An object stores its state in fields (variables in some programming languages) and exposes its behavior through methods (functions in some programming languages). Methods operate on an object's internal state and serve as the primary mechanism for object-to-object communication. Hiding internal state and requiring all interaction to be performed through an object's methods is known as data encapsulation — a fundamental principle of object-oriented programming.
  • 12. Object  Objects are key to understanding object-oriented technology. Look around right now and you'll find many examples of real-world objects: your dog, your desk, your television set, your bicycle. Real-world objects share two characteristics: They all have state and behavior.  Dogs have state<attributes> (name, color, breed, hungry) and behavior (barking, fetching, wagging tail).  Bicycles also have state (current gear, current pedal cadence, current speed) and behavior (changing gear, changing pedal cadence, applying brakes). Identifying the state and behavior for real-world objects is a great way to begin thinking in terms of object-oriented programming.
  • 13. Class  In the real world, you'll often find many individual objects all of the same kind. There may be thousands of other bicycles in existence, all of the same make and model. Each bicycle was built from the same set of blueprints and therefore contains the same components. In object-oriented terms, we say that your bicycle is an instance of the class of objects known as bicycles. A class is the blueprint from which individual objects are created.
  • 14. What Is Inheritance?  Different kinds of objects often have a certain amount in common with each other. Mountain bikes, road bikes, and tandem bikes,  for example, all share the characteristics of bicycles (current speed, current pedal cadence, current gear). Yet each also defines additional features that make them different: tandem bicycles have two seats and two sets of handlebars; road bikes have drop handlebars; some mountain bikes have an additional chain ring, giving them a lower gear ratio.  Object-oriented programming allows classes to inherit commonly used state and behavior from other classes. In this example, Bicycle now becomes the superclass of MountainBike, RoadBike, and TandemBike. In the Java programming language, each class is allowed to have one direct superclass, and each superclass has the potential for an unlimited number of subclasses:
  • 16. Interface  Interface makes the relationship between classes and functionality to those classes implement easier to understand and to design  A interface is a collection of methods that indicate a class has some behavior in addition to what in inherits from supper class;
  • 17. Packages  Packages are use to grouping related classes and interfaces  Java has many packages than make our work lot easier  For take advantages of other packages you must import them
  • 18. Basic PHP Syntax A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the document.
  • 19.  <html> <body> <?php echo "Hello World"; ?> </body> </html>
  • 20. <html> <body> <?php //This is a comment /* This is a comment block */ ?> </body> </html>
  • 21. Variables in PHP  Variables in PHP  Variables are used for storing values, like text strings, numbers or arrays.  When a variable is declared, it can be used over and over again in your script.  All variables in PHP start with a $ sign symbol.
  • 23. Variable ex  $var_name = value;  <?php $txt="Hello World!"; $x=16; ?>  <?php $txt="Hello World"; echo $txt; ?>
  • 24. Variable Ex  <?php $txt1="Hello World!"; $txt2="What a nice day!"; echo $txt1 . " " . $txt2; ?>
  • 25. Strlen & strpos   <?php echo strlen("Hello world!"); ?>  <?php echo strpos("Hello world!","world"); ?>
  • 26. Array  The array functions allow you to manipulate arrays.  PHP supports both simple and multi- dimensional arrays. There are also specific functions for populating arrays from database queries.  Syntax  array(key => value)
  • 27. Array  <?php $a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse"); print_r($a); ?>  <?php $arr = array("foo" => "bar", 12 => true); echo $arr["foo"]; echo $arr[12]; ?>
  • 28. Array  <?php $arr = array(“Horana”,”Colombo”,”Nuwar aeliya”,”Kandi”); echo $arr[1]; echo $arr[4]; ?>
  • 29. PHP Operators Arithmetic Operators Operator Description Example Result + Addition x=2 4 x+2 - Subtraction x=2 3 5-x * Multiplication x=4 20 x*5 / Division 15/5 3 5/2 2.5 % Modulus (division remainder) 5%2 1 10%8 2 10%2 0 ++ Increment x=5 x=6 x++ -- Decrement x=5 x=4 x--
  • 30. Assignment Operators Operator Example Is The Same As = x=y x=y += x+=y x=x+y -= x-=y x=x-y *= x*=y x=x*y /= x/=y x=x/y .= x.=y x=x.y %= x%=y x=x%y
  • 31. Comparison operators Operator Description Example == is equal to 5==8 returns false != is not equal 5!=8 returns true <> is not equal 5<>8 returns true > is greater than 5>8 returns false < is less than 5<8 returns true >= is greater than or equal to 5>=8 returns false <= is less than or equal to 5<=8 returns true
  • 32. Logical Operators Operator Description Example && and x=6 y=3 (x < 10 && y > 1) returns true || or x=6 y=3 (x==5 || y==5) returns false ! not x=6 y=3 !(x==y) returns true
  • 33. Flow Control  IFelse  Switch  While  Do while  For
  • 35. IF else Ex1  <?php $n1 = 50; if(n1>=50){ echo “Pass”; }else{ echo “faille” } ?>
  • 36. Switch  <?php $i = 281; switch ($i) { case “281": echo “Thalgahavila Road"; break; case “315": echo “Meeme Road"; break; case “120": echo “Colombo Road"; break; } ?>
  • 37. While
  • 38. While ex  <?php $i=0; while ($i<5){ echo $i." "."AuD©"."<br/>"; $i++; } ?>
  • 39. Do While  <?php $i=0; do{ echo $i." "."AuD©"."<br/>"; $i++; }while ($i<5) ?>
  • 40. For
  • 41. For  <?php for($i=0;$i<5;$i++){ echo $i." "."AuD©"."<br/>"; }  ?>
  • 42. For each  <?php $x=array("Ashen","Upendra","Disanayaka"); foreach($x as $value){ echo $value." ".".......AuD©........."; }  ?>