SlideShare une entreprise Scribd logo
1  sur  60
Inscribed By: Kian    PHP  &  MySQL  &  Dreamweaver
PART I ,[object Object],[object Object]
Needed Installers ,[object Object],[object Object],[object Object],[object Object],[object Object]
PHP  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Important PHP Features  ,[object Object],[object Object],[object Object],[object Object]
Important PHP Features  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
PHP-Apache Integration PHP Module PHP file Apache Web Server Web Browser Send page Request page HTML doc
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Where does PHP code go? Start PHP mode End PHP mode
Alternate Tags ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Variable Types ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Declaring Variables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],$count  = 0; $name  =  “David" ; $price  = 45.50; $big_num  = 1.2345E23; $success  = TRUE;
Notes About Variables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
More On Variables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Naming Conventions ,[object Object],[object Object],[object Object],[object Object],[object Object]
Constants ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Examples ,[object Object],[object Object]
Three kinds of comments ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Literals & Strings ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Variable Interpolation  ,[object Object],[object Object],[object Object],[object Object]
Variable Interpolation  ,[object Object],[object Object],[object Object],[object Object],[object Object]
Displaying Strings  ,[object Object],[object Object],[object Object],[object Object],[object Object]
Notes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Arithmetical Operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Relational Operators  (Logical Operators) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Comparison Operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Comparison of == and === ,[object Object],[object Object],[object Object],[object Object],[object Object]
Assignment Operators $a = $a % $b $a %= $b %= $a = $a / $b $a /= $b /= $a = $a * $b $a *= $b *= $a = $a - $b $a -= $b -= $a = $a . $b $a .= $b .=   (for strings) $a = $a + $b $a += $b +=   (for numbers) $a = $b $a = $b = Equivalent Example Operator
Expression & Associativity & Evaluation Order ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Functions For Type Testing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Functions For Type Testing ,[object Object],[object Object],[object Object],[object Object]
Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Conditional Statements ,[object Object],[object Object],[object Object],[object Object],[object Object],if  (boolean expression 1) {   ... } elseif  (boolean expression 2) {   ... } else {   ... }
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
For Loop ,[object Object],[object Object],<?php $a = 0;  $b = 0; for  ($i=0; $i < 5; $i++;) { $a += 10; $b += 5; } echo (“At the end of the loop  a=$a and b=$b !”); ?>
While ,[object Object],<?php $i=0; $num=50; while  ($i < 10) { $sum--; $i++; } echo (“Loop stopped at $i</br> num is now $num !”); ?>
Switch ,[object Object],<?php $num = 2; switch  ($num) { case   1: echo (“This is case 1 code!”);   break ; case   2: echo (“This is case 2 code!”);   break ; case   3: echo (“This is case 3 code!”);   break ;   default  :  echo (“This is default code!”);  } ?>
[object Object],Math Functions  <?php $radius  = 1.0; $circ  = 2.0 *  M_PI  *  $radius ; $area  =  M_PI  *  $radius  *  $radius ; echo   &quot;Circumference is $circ&quot; ; echo   &quot;Area is $area&quot; ; ?>
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Math Functions
String Operations  ,[object Object],[object Object],[object Object],[object Object]
String Operations  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String Comparison  ,[object Object],[object Object],[object Object],[object Object],<?php $str1=‘99’;$str2=99; if ( $str1  ===  $str2 ) {  echo   &quot;Strings are equal ! &quot;;  }  else  echo   “Strings are not equal !”; ?>
Substrings & Replacement ,[object Object],[object Object],[object Object],[object Object],[object Object]
Examples of substr_replace ,[object Object],[object Object]
Exploding a String ,[object Object],[object Object],[object Object],<?php  $data = &quot;foo:*:1023:1000::/home/foo:/bin/sh&quot;; list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(&quot;:&quot;, $data); echo $user;   // foo echo $pass;   // *   ?>
Imploding a String ,[object Object],[object Object],[object Object],<?php $array = array('lastname', 'email', 'phone'); $comma_separated = implode(&quot;,&quot;, $array); echo $comma_separated;   // lastname,email,phone ?>
Two types of arrays ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],An array is a data structure that stores one or more values in a single value.
Indexed Arrays  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Indexed Arrays  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Examples ,[object Object],[object Object]
Associative Arrays  ,[object Object],[object Object],$product  = array( 'id'  =>   123 ,  'desc'  =>   null ,    'price'  =>  549 .99 );
Associative Arrays ,[object Object],$age  = array(  'Fred'  => 37,  'Gord'  => 23, 'Alice'  => 17,  'Bob'  => 23 ); echo   &quot;Fred's age is &quot; ,  $age ['Fred']; $age [ 'Fred' ] = 65;  // Fred is now a senior echo   &quot;<br>Fred's age is {$age['Fred']}&quot; ; Note braces needed for interpolation
Sorting Arrays  ,[object Object],[object Object],<?php $names =  array ( 'Fred' ,  'Ted' ,  'Barney' ,  'Gord' ); sort ($names);  // 'Barney','Fred','Gord','Ted' rsort ($names);  // 'Ted','Gord','Fred','Barney‘;  ?>
Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
User-defined Functions ,[object Object],function  name   ($ argument,  $ argument ) { statement1; statement2; }
A max Function ,[object Object],function  max2 ( $a ,  $b ) { $a=3; $b=1;  if ( $a  >  $b )  return $a;  return $b; } echo   “Max of 2 and 3 is &quot; , max2 ( );
Reserved Words in PHP for E_ALL elseif class FALSE endwhile else cfunction extends endswitch echo( ) case exit( ) endif die( ) break eval endforeach do $argc E_WARNING endfor default as E_ERROR enddeclare declare $argv E_PARSE empty( ) continue and
Reserved Words in PHP print( ) not $HTTP_ENV_VARS PHP_VERSION new $HTTP_POST_FILES $PHP_SELF list( ) $HTTP_POST_VARS PHP_OS include_once( ) $HTTP_GET_VARS parent include( ) $HTTP_COOKIE_VARS or if global old_function $HTTP_SERVER_VARS function NULL $HTTP_COOKIE_VARS foreach
Reserved Words in PHP _wakeup TRUE _sleep $this _LINE_ stdclass _FILE_ switch while static virtual( ) return( ) xor require_once( ) var require( )
[object Object],[object Object]

Contenu connexe

Tendances

Php basics
Php basicsPhp basics
Php basics
hamfu
 
Perl.predefined.variables
Perl.predefined.variablesPerl.predefined.variables
Perl.predefined.variables
King Hom
 
Php Reusing Code And Writing Functions
Php Reusing Code And Writing FunctionsPhp Reusing Code And Writing Functions
Php Reusing Code And Writing Functions
mussawir20
 

Tendances (20)

Basic PHP
Basic PHPBasic PHP
Basic PHP
 
Lesson 4 constant
Lesson 4  constantLesson 4  constant
Lesson 4 constant
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
Perl Programming - 02 Regular Expression
Perl Programming - 02 Regular ExpressionPerl Programming - 02 Regular Expression
Perl Programming - 02 Regular Expression
 
Strings,patterns and regular expressions in perl
Strings,patterns and regular expressions in perlStrings,patterns and regular expressions in perl
Strings,patterns and regular expressions in perl
 
perltut
perltutperltut
perltut
 
Php
PhpPhp
Php
 
00 ruby tutorial
00 ruby tutorial00 ruby tutorial
00 ruby tutorial
 
Subroutines in perl
Subroutines in perlSubroutines in perl
Subroutines in perl
 
03phpbldgblock
03phpbldgblock03phpbldgblock
03phpbldgblock
 
Php basics
Php basicsPhp basics
Php basics
 
Php basics
Php basicsPhp basics
Php basics
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requirePHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and require
 
Perl.predefined.variables
Perl.predefined.variablesPerl.predefined.variables
Perl.predefined.variables
 
Php
PhpPhp
Php
 
Php Reusing Code And Writing Functions
Php Reusing Code And Writing FunctionsPhp Reusing Code And Writing Functions
Php Reusing Code And Writing Functions
 
Regular expressions in Perl
Regular expressions in PerlRegular expressions in Perl
Regular expressions in Perl
 
Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 

Similaire à P H P Part I, By Kian

The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
zone
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
birbal
 

Similaire à P H P Part I, By Kian (20)

The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de Javascript
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 
Javascript
JavascriptJavascript
Javascript
 
What Is Php
What Is PhpWhat Is Php
What Is Php
 
unit 1.pptx
unit 1.pptxunit 1.pptx
unit 1.pptx
 
Perl Introduction
Perl IntroductionPerl Introduction
Perl Introduction
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Introduction in php
Introduction in phpIntroduction in php
Introduction in php
 
02 Php Vars Op Control Etc
02 Php Vars Op Control Etc02 Php Vars Op Control Etc
02 Php Vars Op Control Etc
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1
 
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
 
Introduction to php basics
Introduction to php   basicsIntroduction to php   basics
Introduction to php basics
 
Php1
Php1Php1
Php1
 
John Rowley Notes
John Rowley NotesJohn Rowley Notes
John Rowley Notes
 
Introduction To Php For Wit2009
Introduction To Php For Wit2009Introduction To Php For Wit2009
Introduction To Php For Wit2009
 
LPW: Beginners Perl
LPW: Beginners PerlLPW: Beginners Perl
LPW: Beginners Perl
 
Php Basic
Php BasicPhp Basic
Php Basic
 
Babitha5.php
Babitha5.phpBabitha5.php
Babitha5.php
 

P H P Part I, By Kian

  • 1. Inscribed By: Kian  PHP & MySQL & Dreamweaver
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. PHP-Apache Integration PHP Module PHP file Apache Web Server Web Browser Send page Request page HTML doc
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28. Assignment Operators $a = $a % $b $a %= $b %= $a = $a / $b $a /= $b /= $a = $a * $b $a *= $b *= $a = $a - $b $a -= $b -= $a = $a . $b $a .= $b .= (for strings) $a = $a + $b $a += $b += (for numbers) $a = $b $a = $b = Equivalent Example Operator
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57. Reserved Words in PHP for E_ALL elseif class FALSE endwhile else cfunction extends endswitch echo( ) case exit( ) endif die( ) break eval endforeach do $argc E_WARNING endfor default as E_ERROR enddeclare declare $argv E_PARSE empty( ) continue and
  • 58. Reserved Words in PHP print( ) not $HTTP_ENV_VARS PHP_VERSION new $HTTP_POST_FILES $PHP_SELF list( ) $HTTP_POST_VARS PHP_OS include_once( ) $HTTP_GET_VARS parent include( ) $HTTP_COOKIE_VARS or if global old_function $HTTP_SERVER_VARS function NULL $HTTP_COOKIE_VARS foreach
  • 59. Reserved Words in PHP _wakeup TRUE _sleep $this _LINE_ stdclass _FILE_ switch while static virtual( ) return( ) xor require_once( ) var require( )
  • 60.