1 / 12

Introduction to PHP

Introduction to PHP. Data type Operators Statements. Data Type. Integer 4 bytes 1,2, 56, -12 Float 1.23, 3000.45 String “11AA”, “rrrr” Boolean ?? 0, 0.0, “”: false Others: true. Datatype. integer double string array object class unknown type. Variables. Case-sensitive

dom
Télécharger la présentation

Introduction to PHP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to PHP Data type Operators Statements

  2. Data Type • Integer • 4 bytes • 1,2, 56, -12 • Float • 1.23, 3000.45 • String • “11AA”, “rrrr” • Boolean ?? • 0, 0.0, “”: false • Others: true

  3. Datatype • integer • double • string • array • object • class • unknown type

  4. Variables • Case-sensitive • $VariableName • $i, $moon, • Build-in function is not case-sensitive • echo() ?? ECHO() • Declaration • $num=10; • $num=10.0 • $num=“OOOO” • Ex: $k=10; $ks=“112HHHH”; • $addv=$k+$ks; ?? • $c=$a+$b;

  5. Constant • Ex: • PI=3.14; • Syntax • Define(“PI”,3.14) • PI=39.34; • PI=$a+$b;

  6. Build-in Functions • Gettype() • $i=30; • Echo(Gettype($i)) ?? • Settype() • $a=7.8; • Settype($a, “integer”) • …

  7. Struct • Protein ?? • ID • Name • AtomNum • Type • $protein->id • $protein->name • $protein->atomnum • $protein->type

  8. Operators • Calculation operators • +,-,*,/ • ++,-- • $a=10; $a++; /* a=? $a=$a+1;*/ • $a=10; $b=$a++; /* a=? , b=? */ • $a=10; $b=++$a; /* a=? , b=? */ • Boolean • >=,<=,!=,>,< • && (and) , || (or), • $I=10; • If (9=$I) echo “11111”; • String • . • $aa=“AAA” . “CCCC”; • @

  9. Statements-1 • if ..then .. Else if ( $SNum > $ENum) $R= ">"; else if ( $SNum < $ENum) $R= "<"; else $R="=="; echo("$SNum $R $ENum");

  10. Statements-2 • Switch <? $OperType = “a”; • Switch { Case.. } switch ($OperType) { case "a": $a = $SNum + $ENum; echo("$SNum + $ENum = " . $a ); case "s": $a= $SNum-$ENum; echo("$SNum - $ENum = " . $a); break; } ?>

  11. Statements-3 • Loop (sum 1 to 100) • While { … } $Sum=0; $i=0; while ($Snum < $ENum) { // ?? $sum=$sum+$i; // ?? $i++; } // minimum executing time is 0 • Do {… } while <<see test1>> $Sum=0; $i=$Snum; do { $Sum=$Sum+$i; $i++; } while ($i<= $Enum); //minimum executing time is 1

  12. Statements-4 • For ( ; ; ) { …} $Sum=0; $k=0; for ($i=$SNum;$i<=$ENum;$i++,$k++) $Sum=$Sum+$i;

More Related