Introduction to PHP (Part-2)
Associative arrays:
$array-name[‘element-name’]=value
$players[‘yousuf’]=“Muhammad Yousuf”;
Adding element in an array:
$players[‘younus’]=“Younus Khan”;
Accessing element in an array:
echo $players[‘yousuf’];
40 trang |
Chia sẻ: dntpro1256 | Lượt xem: 732 | Lượt tải: 0
Bạn đang xem trước 20 trang tài liệu Introduction to PHP (Part-2), để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
Introduction to PHP (Part-2)Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.1Summary of the previous lectureSetting the environmentOverview of PHPConstants and Variables in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.2OutlineOperators in PHPConditional Statements in PHPLooping StatementsArrays in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.31. Operators in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.4Arithmetic Operators: +, - ,*, /, %Assignment Operators: =+= ($a +=$b ), *= , /=.= ($a .= $b)1. Operators in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.5Adds $b in $aConcatenates $b with $a1. Operators in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.61. Operators in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.7String Operators: . , .=$a=“abcd”.”efgh”; $a=abcdefgh$a.=“ijk”; $a=abcdefghijk Increment/decrement Operators: ++,--$b=$a++$b=++$a1. Operators in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.8First variableSecond variableConcatenationUsing .=1. Operators in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.91. Operators in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.10Variable declaredIncremented before displayIncremented after displayDisplaying incremented value1. Operators in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.111. Operators in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.12Logical Operators: AND, OR, NOT, XOR&&, ||, !Equality Operators: ==, !=, === Comparison Operators: >, =1. Operators in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.13Integer valueString valueCompares only valuesStrict comparison1. Operators in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.142. Conditional Statementsif statement:if(condition) { }if-else statement:if(condition) { } else { }Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.152. Conditional Statementsswitch statement:switch(variable){case option: actionbreak;..}Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.162. Conditional StatementsBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.17Switch startscase 0Case 12. Conditional StatementsBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.183. Looping Statementsfor loopwhile loopdo-while loopforeach loopBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.193. Looping Statementsfor loopfor($a=0; $a“M.Yoursuf”,”imran”=>”Imran Khan”);Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.314. Arrays in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.32Associative array is created using array()Accessing elements by name4. Arrays in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.334. Arrays in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.34Sorting arrays:sort()rsort()4. Arrays in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.35Array is createdArray is sortedArray is displayed4. Arrays in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.364. Arrays in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.37rsort() is used4. Arrays in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.38SummaryOperators in PHPConditional statementsLooping statementsArrays in PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.39References Chapter 2, “Beginning PHP6,Apache,Mysql web development” by Matt Doyle, Wrox publishers, 2009, ISBN: 0470413964 Chapter 5, “Beginning PHP and MySQL” by W. Jason Gilmore, Apress publisher, 4th edition; 2010, ISBN-13 (electronic): 978-1-4302-3115-8.Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.40
Các file đính kèm theo tài liệu này:
- lec25_introduction_to_php_part_2_7884_2026973.pptx