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
290
1
Share
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
310
Use PaaS service to host your web - with pagodabox
lucienlee
0
83
final album
lucienlee
0
75
Simple Album
lucienlee
0
96
Accessing MySQL from PHP
lucienlee
1
370
DataBase and MySQL
lucienlee
1
240
PHP 101: flow control
lucienlee
0
330
Start to Build your Web
lucienlee
1
430
既然如此,那我們來hack資本世界吧!
lucienlee
0
160
Other Decks in Programming
See All in Programming
〜バイブコーディングを超えて〜 チームで実験し続けたAI駆動開発
tigertora7571
0
150
PHPer、Cloudflare に引っ越す
suguruooki
1
100
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
560
AIエージェントで業務改善してみた
taku271
0
540
AIベース静的検査器の偽陽性率を抑える工夫3選
orgachem
PRO
3
350
TiDBのアーキテクチャから学ぶ分散システム入門 〜MySQL互換のNewSQLは何を解決するのか〜 / tidb-architecture-study
dznbk
1
180
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
24
14k
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
感情を設計する
ichimichi
5
1.5k
Oxlintとeslint-plugin-react-hooks 明日から始められそう?
t6adev
0
280
UIの境界線をデザインする | React Tokyo #15 メイントーク
sasagar
2
380
アーキテクチャモダナイゼーションとは何か
nwiizo
19
5.4k
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
698
190k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
sira's awesome portfolio website redesign presentation
elsirapls
0
220
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
320
Tell your own story through comics
letsgokoyo
1
900
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
680
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
680
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
530
Navigating Team Friction
lara
192
16k
From π to Pie charts
rasagy
0
170
Test your architecture with Archunit
thirion
1
2.2k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
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