Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PHP 101: flow control
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
LucienLee
June 27, 2013
Programming
330
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PHP 101: flow control
Fundamental PHP & Web Development
LucienLee
June 27, 2013
More Decks by LucienLee
See All by LucienLee
SASS & Compass 101
lucienlee
1
310
Use PaaS service to host your web - with pagodabox
lucienlee
0
86
final album
lucienlee
0
78
Simple Album
lucienlee
0
100
Accessing MySQL from PHP
lucienlee
1
380
DataBase and MySQL
lucienlee
1
240
PHP 101+1:function & form
lucienlee
1
300
Start to Build your Web
lucienlee
1
440
既然如此,那我們來hack資本世界吧!
lucienlee
0
160
Other Decks in Programming
See All in Programming
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
210
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
570
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.4k
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
8k
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
210
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
790
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
280
Webフレームワークの ベンチマークについて
yusukebe
0
180
さぁV100、メモリをお食べ・・・
nilpe
0
150
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
320
Creating Composable Callables in Contemporary C++
rollbear
0
170
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
560
Featured
See All Featured
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
40k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
620
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Utilizing Notion as your number one productivity tool
mfonobong
4
330
Tell your own story through comics
letsgokoyo
1
970
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
220
Exploring anti-patterns in Rails
aemeredith
3
430
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
750
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Transcript
PHP 101: flow control Fundamental PHP & Web Development lecturer
: Lucien Lee 李柏緯 Lecture 2
? What is flow control 2
3 eat SLEEP DRINK PUPU Straight Life
4 Real Life is complicated
5 Based Condition, Decide what to do.
IF 6 if something happen, what should we do?
IF •If my dog is gone, I call its name.
7
IF if($dog == ‘gone’){ echo “Where are you, Lucy!”; }
8
IF..ELSE.. 9 more statement to if not
ELSE •If my dog is gone, I call its name;
else I play with it. 10
ELSE if($dog == ‘gone’){ echo “Where are you, Lucy!”; }else{
$myState = “play”; } 11
ELSEIF 12 Give MOre condition and RESPonse
ESLEIF •If my dog is gone, I call its name;
else if my dog is eating, I go to eat. 13
ELSEIF if($dog == ‘gone’){ echo “Where are you, Lucy!”; }elseif($dog
== ‘eating’){ $myState = “go to eat”; } 14
? LOOP 15
16 eat SLEEP DRINK PUPU But you get older
17 for Do one by one, until satisfy condition.
18 for •Count from 1 to 10.
for for($i=1; $i<=10; $i++){ echo $i.’<br>’; } 19
20 while Do again by again, until satisfy condition.
21 while •Count from 1 to 10.
while $i=1 while($i<=10){ echo $i.’<br>’; i++; } 22
23 foreach traverse array one by one
foreach $price = array(“apple”=>100, ”orange”=>150, “banana”=>200); foreach($price as $key =>
$value){ echo “水果: ”. $key.”/價錢: ”. $value; } 24
ARRAY Part 2 25
? Multi-Array 26
ARRAY •a collection of data items. •key map to value.
•Like many box put together. 27 Apple 100 Orange 150 Banana 200
28 0 1 2 0 A B C 1 D
E F 2 G H I Multi-Case
Multi-Array 29 $array[0][‘cool’] = ‘awesome’; $array[1] = “XD”; $array[0][1][‘yeah’] =
“yo”; //wrong case $array[0]=100;
key-value 30 red white yellow purple flower rose lily sumflower
fruit apple pear banana grape
Multi-Array 31 $set=array( ‘flower’=>array(‘red’=>‘rose’,‘whit e’=>‘lily’,‘yellow’=>‘sunflower’), ‘fruit’=>array(‘red’=>‘apple’, ‘white’=>‘pear’,‘yellow’=>‘banana’, ‘purple’=>‘grape’) );
+ union two array 32
two array plus $item1 = array(‘rose’,‘lily’); $item2 = array(‘apple’,‘banana’,‘grape’); $items
= $item1 + $item2; //$items = array(‘rose’,‘lily’, ‘grape’); 33
array_push() add a new data to array 34
array_pop() remove last data from array 35
Live Coding 36
HomeWork 37 • make key-value array to save student grade.
• All grade * 1.4, if modified grade over 100, modify in another way:original value + (100 - original value)*0.1 • change array as name map to array save grade and pass or not. a b c d e f 30 40 90 60 55 80