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+1:function & form
Search
LucienLee
July 02, 2013
Programming
300
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PHP 101+1:function & form
Fundamental PHP & Web Development
LucienLee
July 02, 2013
More Decks by LucienLee
See All by LucienLee
SASS & Compass 101
lucienlee
1
320
Use PaaS service to host your web - with pagodabox
lucienlee
0
87
final album
lucienlee
0
79
Simple Album
lucienlee
0
100
Accessing MySQL from PHP
lucienlee
1
380
DataBase and MySQL
lucienlee
1
240
PHP 101: flow control
lucienlee
0
330
Start to Build your Web
lucienlee
1
440
既然如此,那我們來hack資本世界吧!
lucienlee
0
160
Other Decks in Programming
See All in Programming
源内ハンズオン概要編
hideg
0
210
Go 1.27 における memory allocation の高速化
andpad
0
310
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
540
Go 1.27からのGODEBUG / Go 1.27 リリースパーティ #go127party
mazrean
0
200
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4.2k
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
720
MySQLとPostgreSQLって何が違うの?
akagami
0
130
DynamoDBの基礎を振り返りながらベクトル検索機能を理解する
musan
2
170
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
370
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
480
引き算の組織 ― アウトカムとAIに全振りするために辞めたこと ― / Organization by Subtraction
hirokiyamamoto14
PRO
0
290
今さら聞けない .NET CLI
htkym
0
210
Featured
See All Featured
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
520
WENDY [Excerpt]
tessaabrams
11
39k
Making the Leap to Tech Lead
cromwellryan
135
10k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
430
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
67
57k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
360
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.1k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
580
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
220
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
Balancing Empowerment & Direction
lara
6
1.2k
How to Ace a Technical Interview
jacobian
281
24k
Transcript
PHP 101+1:function & form Fundamental PHP & Web Development lecturer
: Lucien Lee 李柏緯 Lecture 3
? What is function 2
function 3 give input and send back output
4 function IN out
5 feature function IN out
function 6 function Name([arguments]){ statements; return output; }
function example function discount($price){ $price *= 0.8; return $price; }
7
use function $item1 = 1000; echo discount($item1); ---Another place--- $item2
= 800; echo discount($item2); 8
variable scope 9 Does the variable still alive?
Scope 10 $Julia $global function A $Liz function B $global
$Julia $global $Liz $global
Scope $A = “hello”; echo $A; //”hello” function inner(){ $A
= “world”; echo $A; //”world” } 11
some function 12 introduce some php function
isset() Determine if a variable is set and is NULL.
13
empty() Determine whether a variable is empty 14
time() number of seconds since the Unix Epoch 15
date($format) return date info with format 16
rand([min,max]) get random value 17
array_search(value,array) find value exist in array or not 18
! form: basic way pass info to back 19
form 20 from wikipedia
form <form action=”URL” method=”{post, get}” name=”example”> input element </form> 21
from 22 •action: Specifies where to send the form-data when
a form is submitted. •method: Specifies the HTTP method to use when sending form-data. •name:Specifies the name of a form.
Text Fields <input type="text" name="firstname"> 23 from w3schools
Password Field <input type="password" name="pwd"> 24 from w3schools
Radio Buttons <input type="radio" name="sex" value="male"> <input type="radio" name="sex" value="female">
25 from w3schools
Checkboxes <input type="checkbox" name="vehicle" value="Bike"> <input type="checkbox" name="vehicle" value="Car"> 26
from w3schools
textarea <textarea rows="4" cols="50"> At w3schools.com you will learn how
to make a website. We offer free tutorials in all web development technologies. </textarea> 27 from w3schools
select <select> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option>
</select> 28 from w3schools
Button <button type="button">Click Me!</button> 29
Submit Button <input type="submit" value="Submit"> 30
? GET & POST 31
HTTP method 32 request and tell server what to do
GET •Retrieve data •remain in the browser history •never be
used when dealing with sensitive data •have length restrictions 33
POST •query sent in HTTP message body •do not remain
in the browser history •no restrictions on data length •(as create in RESTful) 34
35 GET POST
more method •HEAD •PUT •DELETE •TRACE •CONNECT •...... 36
? How to retrieve message in server 37
IN SERVER 38 •$_GET[‘name’] •$_POST[‘name’]
Live Coding 39
HomeWork 40 • make a drink order form and when
user confirm, calculate the total money. • if amount of drinks is greater than 10, all drinks have 10% discount. • ceiling the final price.
Test Data 41
HomeWork Advanced 42 • make a drink order form and
when user confirm, calculate the total money. • ordering black tea and green tea together has 20% discount. • expect drinks with above-mentioned discount, if amount of drinks is greater than 10, these drinks have 10% discount.
Test Data 43