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
1
290
PHP 101+1:function & form
Fundamental PHP & Web Development
LucienLee
July 02, 2013
Tweet
Share
More Decks by LucienLee
See All by LucienLee
SASS & Compass 101
lucienlee
1
300
Use PaaS service to host your web - with pagodabox
lucienlee
0
81
final album
lucienlee
0
73
Simple Album
lucienlee
0
94
Accessing MySQL from PHP
lucienlee
1
370
DataBase and MySQL
lucienlee
1
230
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
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
190
「ちょっと古いから」って避けてた技術書、今だからこそ読もう
mottyzzz
10
6.5k
どの様にAIエージェントと 協業すべきだったのか?
takefumiyoshii
2
640
Signals & Resource API in Angular: 3 Effective Rules for Your Architecture @BASTA 2025 in Mainz
manfredsteyer
PRO
0
120
monorepo の Go テストをはやくした〜い!~最小の依存解決への道のり~ / faster-testing-of-monorepos
convto
2
460
uniqueパッケージの内部実装を支えるweak pointerの話
magavel
0
970
バッチ処理を「状態の記録」から「事実の記録」へ
panda728
PRO
0
140
なぜあの開発者はDevRelに伴走し続けるのか / Why Does That Developer Keep Running Alongside DevRel?
nrslib
3
390
あなたとKaigi on Rails / Kaigi on Rails + You
shimoju
0
120
NetworkXとGNNで学ぶグラフデータ分析入門〜複雑な関係性を解き明かすPythonの力〜
mhrtech
3
1.2k
Devoxx BE - Local Development in the AI Era
kdubois
0
120
Railsだからできる 例外業務に禍根を残さない 設定設計パターン
ei_ei_eiichi
0
440
Featured
See All Featured
Bash Introduction
62gerente
615
210k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Speed Design
sergeychernyshev
32
1.2k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Music & Morning Musume
bryan
46
6.8k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.7k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.1k
Designing for Performance
lara
610
69k
Context Engineering - Making Every Token Count
addyosmani
5
220
Mobile First: as difficult as doing things right
swwweet
224
10k
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