0
Server Side Scripting Language for Dynamic Web Page Development

Open Source

Supports Large Number of Databases

It can w...
Resembles C, C++ and Perl
HTTP Authentication
Cookies
Sessions
File Uploads
Remote File Handling
Persistent Database Conne...
+ H OOR : R U OG
KWPO!
 KH D G !
    WL WOH !3 + 3 7 U D L Q L Q J  WL WOH !
  KH D G !
 E R G  E J F R OR U ) ) ) )   !

...
The Server Time Now 15:44:31
KWPO!
 KH D G !
    WL WOH !3 + 3 7 U D L Q L Q J  WL WOH !
  KH D G !
 E R G  E J F R OR U )...
Welcome Trainees
KWPO!
 KH D G !
    WL WOH !3 + 3 7 U D L Q L Q J  WL WOH !
  KH D G !
 E R G  E J F R OR U ) ) ) )   !

...
+ +4   5




           6



7      

8              8   8 8
!       quot; #
        )

4,,9 ;
    :              (       =:

     
     /             (       # +
                    ...
quot; $
,                           (                   )   quot;(   '

(       ?E G
          N 2          E G
          ...
%    #
S        M   S   )                

(            S

(        P   S

(P           /                            H

( ...
'   #   #
S   M                         S   )                  

6   quot;     ! Q'                S

6   quot;     E!2 W'...
(quot;       #
;       ,        

,                    :F                 H

    U
    O
    U                            ...
(quot;    #
;
        ,   

,                :F                   H

                                 *

    O            ...
(quot;   #
4    ,       

,                 :F                         H

    X                  -    .

    Y            ...
(quot;   #
7          ,           

,                           :F                  H

                    +              ...
(quot;   #
9        ,   

,                :F               H

; 6                        )8            )8

    ,         ...
(quot;            #
:    7       ,

,                    :F                                 H

    ]            =    
    ...
(quot;    #
;       ),
        ),   

,                    :F                      H

    O         8                     ...
'   )*
if ($sex==‘M’)
{
echo “Welcome Sir”;
}


if ($sex==‘M’)
{
 echo “Welcome Sir”;
}else{
 echo “Welcome Madam”;
}


if...
'   )*
if ($sex==‘M’):
echo “Welcome Sir”;
endif;



if ($sex==‘M’):
 echo “Welcome Sir”;
else:
 echo “Welcome Madam”;
edn...
'                     +

while ($x10)
{
echo “The Value of X is u$x/u now br”;
$x++;
}




while ($x10):
echo “The Value o...
'                     , - .


do
{
echo “The Value of X is u$x/u now br”;
$x++;
} while ($x=10)
'                      *


For($x=1; $x=10;$x++)
{
echo “The Value of X is u$x/u now br”;
}



For($x=1; ;$x++)
{
echo “Th...
'                      *


For($x=1; $x=10;$x++):
echo “The Value of X is u$x/u now br”;
endfor;




For($x=1; ;$x++):
ech...
'                     *


$x = array (1,2,3,4,5,6,7,8,9,10);

foreach($x as $v)
{
echo “The Value of X is u$v/u now br”;
}...
'                       /


while($rows=8)
{ // Block 3
   for($col=1;$col=8;$col++)
   {     // Block 2
         foreach(...
'


$i = 0;
while ($i++  5)
{
    echo “I am in Outer Zone brquot;;
    while (TRUE)
    {
        echo “Now in Middle Zon...
'              #.

Switch ($x)
{
case 1:
echo “Value   of X is 1 br“;
break;
case 2:
echo “Value   of X is 2 br“;
break;
c...
'              0   123   , 12


require ‘conf.php’;

require $conffile;

require (“conf,php”);




include ‘conf.php’;

in...
'                         0   4   123   , 4   12


require_once(‘conf.php’);

include_once($conffile);
5# 6 *        ,7       #


function hellow($x,$y=“, How are You?”)
{
echo “Hello $x $y br”;
}

hellow(‘Sir’);
hellow(‘Arju...
7                      %      #


function power($x,$y)
{
$z=1;
for($a=1;$a=$y;$a++){$z *= $x;}
return $z;
}

echo “5sup2/...
%     7         #

function power($x,$y)
{
$z=1;
for($a=1;$a=$y;$a++){$z *= $x;}
return $z;
}
$pwr = ‘power’;

echo “5sup2...
' ##
class LAMP
{
var $strength=0; var $trainee;
function Add_Trainee($name,$designation)
         {
         $this-streng...
' ## 8 )

class A
          {
          function X() {echo quot;I am From Function X of Class A brquot;;}
          }

cla...
9         7             #
;  $
  ; *7 = _

     )     )*   H 5quot;           )       H!       ` - M
                     ...
6          ,         7   #
6; :

           quot;                 -!                 .'



            quot; Bb $
        ...
7 ##                7                 #
7 $
 ,+

M        )quot;            H      !             '
                       ...
:                 7   #
J

     L quot;               '
           quot;               '
(          quot; '
           L (...
:     ; 7                   #
I$ J9 ,
     *7        :7

    H        ) L*
                              quot;-           ...
=              7         #
: :
  7

        F        quot;    -!            )X H H -!       X   H *   . '
                ...
7          #
: ,
 7

               quot;                -
                                 !       CCC.'
#
         ? H
 ...
95   = ) )  + )
                           '9 (

?php

if (!isset($_SERVER['PHP_AUTH_USER']))
{
    header('WWW-Authentica...
'( ( ?)=

     #   / #       $%       quot;   $%    $%      $%
$%        $%        '


?php
start_session();
Setcookie(‘my...
= ) 
                               (

   (
?php
start_session();
$_SESSION[‘myuser’] = ‘trainee1’;
?

   )
?php
start_ses...
7         ,
html
body
 form method=post
p align=center Enter Your Name nbsp nbsp input type=text
name=mynamebr
input type=...
LAMP_TRAINING_SESSION_7
LAMP_TRAINING_SESSION_7
LAMP_TRAINING_SESSION_7
LAMP_TRAINING_SESSION_7
LAMP_TRAINING_SESSION_7
LAMP_TRAINING_SESSION_7
LAMP_TRAINING_SESSION_7
LAMP_TRAINING_SESSION_7
LAMP_TRAINING_SESSION_7
LAMP_TRAINING_SESSION_7
LAMP_TRAINING_SESSION_7
LAMP_TRAINING_SESSION_7
LAMP_TRAINING_SESSION_7
LAMP_TRAINING_SESSION_7
Upcoming SlideShare
Loading in...5
×

LAMP_TRAINING_SESSION_7

804

Published on

Presentaions of LAMP Training Conducted by T.Umapathi Anand and R.Kasturi from Southern Telecom Region, BSNL at RTTC Trivandrum.

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
804
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
35
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "LAMP_TRAINING_SESSION_7"

  1. 1. Server Side Scripting Language for Dynamic Web Page Development Open Source Supports Large Number of Databases It can work as Server Module or as Stand Alone CGI Script
  2. 2. Resembles C, C++ and Perl HTTP Authentication Cookies Sessions File Uploads Remote File Handling Persistent Database Connections Command Line Interpretation Portable Code
  3. 3. + H OOR : R U OG KWPO! KH D G ! WL WOH !3 + 3 7 U D L Q L Q J WL WOH ! KH D G ! E R G E J F R OR U ) ) ) ) ! E R G ! KWPO!
  4. 4. The Server Time Now 15:44:31 KWPO! KH D G ! WL WOH !3 + 3 7 U D L Q L Q J WL WOH ! KH D G ! E R G E J F R OR U ) ) ) ) ! ! quot;$ % '! #% # E R G ! KWPO!
  5. 5. Welcome Trainees KWPO! KH D G ! WL WOH !3 + 3 7 U D L Q L Q J WL WOH ! KH D G ! E R G E J F R OR U ) ) ) ) ! ( ) (*+, - ) # . /quot;( ) 0 #' 1 2 ( ) 2 3 I R U P PH WKR G S R V W! S D OL J Q F H Q WH U ! ( Q WH U R X U 1 D PH L Q S X W W S H WH [ W Q D PH P Q D PH ! S ! I R U P! E R G ! KWPO!
  6. 6. + +4 5 6 7 8 8 8 8
  7. 7. ! quot; # ) 4,,9 ; : ( =: / ( # + + ( ? + + 2 / / : ( @ A B ,; 9 ( A CD A E ( ,F @ 7 G ; : 7 H ) ; $ ; ( ) # H! quot;) ! ' ( )quot; 9 H !E F ; ! I) J9! + + ' ,4 : K7 ( I) quot; 7 ' ) ,= : : 7 ( ) L *L H )? quot; 8 MC M 2' =99 ( H
  8. 8. quot; $ , ( ) quot;( ' ( ?E G N 2 E G N / ( O D P E Q / : : ( QQ ECP B ,; 9 ( ( C?R2 ECPR /
  9. 9. % # S M S ) ( S ( P S (P / H ( * S (* / = ( T S ( U / / ; 7 /7 QV E@ ( / S M : S 6 : :
  10. 10. ' # # S M S ) 6 quot; ! Q' S 6 quot; E!2 W''' 2' S S E G N / ) F 6 quot;# !B 9: ; ' S 6 quot;E ! Q' / H 6 quot;* *! Q' S 6 quot;# Q !P ' / ; 6 quot;**9 : / **! ' =: / I 7 : S 6 : :
  11. 11. (quot; # ; , , :F H U O U ! 8 quot; # $ !% ' % R quot; ( ) %
  12. 12. (quot; # ; , , :F H * O + % U + % 8 # + % # + % R ( + % ( C , + % ,
  13. 13. (quot; # 4 , , :F H X - . Y / . . Z 0 1 . . % [ 2 % . % 5 3 44 % 3 ! * . % 5 ) 66 % ) 7 % *
  14. 14. (quot; # 7 , , :F H + )8 + 9 )8 + 0 + : )8 + + 46 )8 + )8 + 0 9 : 3 4 )8 ; 6 )8 3 + 4 )8 + ; + 6 )8 +
  15. 15. (quot; # 9 , , :F H ; 6 )8 )8 , )8 )8 , 0 )8 )8 0 : )8 )8 XX )8 )8 YY )8 )8 , , :F H C ,
  16. 16. (quot; # : 7 , , :F H ] = ? A , @B C ? , @ :F H , , :F H ^ D ED ,+ % F B A / 6 , , :F H 9 ) * OO ) * 9 ! ) * UU ) * !
  17. 17. (quot; # ; ), ), , :F H O 8 5 % + )8 % G % )8 % G % 9 0 9 + : )8 + 9 + : )8 + 0 9 : )8 ) , , :F H 7 HI J
  18. 18. ' )* if ($sex==‘M’) { echo “Welcome Sir”; } if ($sex==‘M’) { echo “Welcome Sir”; }else{ echo “Welcome Madam”; } if ($sex==‘M’) { echo “Welcome Sir”; } elseif ($sex==‘F’) { echo “Welcome Madam”; }else{ echo “Welcome”; }
  19. 19. ' )* if ($sex==‘M’): echo “Welcome Sir”; endif; if ($sex==‘M’): echo “Welcome Sir”; else: echo “Welcome Madam”; ednif; if ($sex==‘M’): echo “Welcome Sir”; elseif ($sex==‘F’): echo “Welcome Madam”; else: echo “Welcome”; endif;
  20. 20. ' + while ($x10) { echo “The Value of X is u$x/u now br”; $x++; } while ($x10): echo “The Value of X is u$x/u now br”; $x++; endwhile;
  21. 21. ' , - . do { echo “The Value of X is u$x/u now br”; $x++; } while ($x=10)
  22. 22. ' * For($x=1; $x=10;$x++) { echo “The Value of X is u$x/u now br”; } For($x=1; ;$x++) { echo “The Value of X is u$x/u now br”; If($x==10)break; } For(;;) { $x++; if($x10)break; echo “The Value of X is u$x/u now br”; }
  23. 23. ' * For($x=1; $x=10;$x++): echo “The Value of X is u$x/u now br”; endfor; For($x=1; ;$x++): echo “The Value of X is u$x/u now br”; If($x==10)break; endfor; For(;;): $x++; if($x10)break; echo “The Value of X is u$x/u now br”; endfor;
  24. 24. ' * $x = array (1,2,3,4,5,6,7,8,9,10); foreach($x as $v) { echo “The Value of X is u$v/u now br”; } $x = array (“one”=1,”two”=2,”three”=3,”four”=4,”five”=5, “six”=6,”seven”=7,”eight”=8,”nine”=9,”ten”=10); foreach($x as $p=$v) { echo “The Value of $p is u$v/u now br”; }
  25. 25. ' / while($rows=8) { // Block 3 for($col=1;$col=8;$col++) { // Block 2 foreach($x as $v) { // Block 1 if($v==8) break; if($v==0) break 2; if($v0) break 3; echo $v; } echo “br”; } $rows++; }
  26. 26. ' $i = 0; while ($i++ 5) { echo “I am in Outer Zone brquot;; while (TRUE) { echo “Now in Middle Zone brquot;; while (TRUE) { echo “Now in Inner Zone brquot;; echo “-----------------------------------($i)br”; continue 3; } echo quot;This never gets outputquot;; } echo quot;Neither does thisquot;; }
  27. 27. ' #. Switch ($x) { case 1: echo “Value of X is 1 br“; break; case 2: echo “Value of X is 2 br“; break; case 3: echo “Value of X is 3 br“; break; case 4: case 5: echo “Value of X is 4 br“; break; default: echo “Value of X is $x br”; }
  28. 28. ' 0 123 , 12 require ‘conf.php’; require $conffile; require (“conf,php”); include ‘conf.php’; include $conffile; include (“conf,php”);
  29. 29. ' 0 4 123 , 4 12 require_once(‘conf.php’); include_once($conffile);
  30. 30. 5# 6 * ,7 # function hellow($x,$y=“, How are You?”) { echo “Hello $x $y br”; } hellow(‘Sir’); hellow(‘Arjun’,’When Did You Come?’); hellow(‘Ram’,’’); Hello Sir, How are You? Hello Arjun When Did You Come? Hello Ram
  31. 31. 7 % # function power($x,$y) { $z=1; for($a=1;$a=$y;$a++){$z *= $x;} return $z; } echo “5sup2/sup = “ ,power(5,2), “br”; echo “2sup5/sup = “ ,power(2,5), “br”; 52 = 25 25 = 32
  32. 32. % 7 # function power($x,$y) { $z=1; for($a=1;$a=$y;$a++){$z *= $x;} return $z; } $pwr = ‘power’; echo “5sup2/sup = “ ,$pwr(5,2), “br”; echo “2sup5/sup = “ ,$pwr(2,5), “br”; 52 = 25 25 = 32
  33. 33. ' ## class LAMP { var $strength=0; var $trainee; function Add_Trainee($name,$designation) { $this-strength++; $this-trainee[$this-strength]['id']=$this-strength; $this-trainee[$this-strength]['name']=$name; $this-trainee[$this-strength]['designation']=$designation; } } $Session1 = new LAMP; $Session1-Add_Trainee('Loo','SDE');$Session1-Add_Trainee('Goo','JTO'); for($n=0; $n=$Session1-strength; $n++) { echo $Session1-trainee[$n]['id'], “...quot;, $Session1-trainee[$n]['name'], quot;...quot;, $Session1-trainee[$n]['designation'], quot;brquot;; } 1...Loo...SDE 2...Goo...JTO
  34. 34. ' ## 8 ) class A { function X() {echo quot;I am From Function X of Class A brquot;;} } class B extends A { function Y() { echo quot;I am From Function Y of Class B brquot;;} } $var = new B; echo $var-X(); echo $var-Y(); I am From Function X of Class A I am From Function Y of Class B
  35. 35. 9 7 # ; $ ; *7 = _ ) )* H 5quot; ) H! ` - M ! *5 ) .' ( ) )* quot; H 5( )N ! ! ' =: ; $ : *: / ; *_ $ M )*5 ) F quot; * F 5)! ) ' ( 5 ) * *5 ) F # quot; ! ( H ' ; $ ; * ; _ 9 M )* 5quot; )X )! M 5 H -! F H .' )* quot; 5 ( H !# + S H ' , M quot; )X )-! * ' . quot; H ( '
  36. 36. 6 , 7 # 6; : quot; -! .' quot; Bb $ a ! ! % a' I/ / 7 , I: F quot;-M * * .' (I) quot; ' =: : 6; : ) quot;- .' ! quot; ( ) quot;'
  37. 37. 7 ## 7 # 7 $ ,+ M )quot; H ! ' !quot; ( )# quot; C ! C ' B : ,+ H quot; ! -M ! H * H * -! H F. ' . # ( quot;a H C F a aa ! ' ; /: : 6B 9 quot; -M ! H * H * -! H F. ' . $ quot; ) # C F ' = 9 _ / M H 5quot; -! H F .' % = 5# ) quot; C F '
  38. 38. : 7 # J L quot; ' quot; ' ( quot; ' L (F +, H M quot; H M M ! H M F ' $ ( quot; !N (F ' ; quot; ' ( quot;Q N ' 6 ; quot;- ! F ' . $ ( quot;! Q Q Q '
  39. 39. : ; 7 # I$ J9 , *7 :7 H ) L* quot;- - ! H - ! -! M * 5-! * .. ' ... # quot;( ! ( F ) L* quot;# ! ! A Q c' I$ J9 , *: ) L* quot;- H 5* .' quot;( ! ) *+ * , ) L* quot;( F' I$ J9 : : *64 * 97 M ) L * * Mquot; M * -! H 5* .' quot; $ * ) L * * M # L' quot; I$ J9*J=: $ H ) L *L H )quot; LH )-! H 5* .' quot;( ! ( ) L *L H )# quot; 8 C H '
  40. 40. = 7 # : : 7 F quot; -! )X H H -! X H * . ' . F quot;# ' +; = Hquot; -! X H * .' H ?V 2 quot; '
  41. 41. 7 # : , 7 quot; - ! CCC.' # ? H $ ?! ( : + ,6: 9 ) F quot; ! -! .' quot; ( ) ) F quot; !2! (9 ? ' : 9 quot; ' quot; H ? 2' =4 M H quot; ! -! .' $ ( M quot; H H ? 2 !@ !c '
  42. 42. 95 = ) ) + ) '9 ( ?php if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm=“Protectedquot;'); header('HTTP/1.0 401 Unauthorized'); echo ‘You Should Login to View the Content'; exit; } else { echo quot;pHello {$_SERVER['PHP_AUTH_USER']}./pquot;; echo quot;pYou entered {$_SERVER['PHP_AUTH_PW']} as your password./pquot;; } ?
  43. 43. '( ( ?)= # / # $% quot; $% $% $% $% $% ' ?php start_session(); Setcookie(‘myuser’,‘trainee1’); Setcookie(‘myuser’,‘trainee1’, time()+3600); Setcookie(‘myuser’,‘trainee1’, time()+3600, ‘/olq’); ? ?php echo $_COOKIE[‘myuser’]; ?
  44. 44. = ) ( ( ?php start_session(); $_SESSION[‘myuser’] = ‘trainee1’; ? ) ?php start_session(); echo $_SESSION[‘myuser’]; ?
  45. 45. 7 , html body form method=post p align=center Enter Your Name nbsp nbsp input type=text name=mynamebr input type=submit name=button value=Process input type=hidden name=hiddenfield value=100 /p ?php $button = $_POST['button']; If($button!='') { $name = $_POST['myname']; $hidden_value = $_POST['hiddenfield']; $shrink = strlen($name); echo quot;Your name b$name/b is of $shrink Character Length. brquot;; echo quot;Your Hidden Field Value is quot;, $hidden_value; } ? /body /html
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×