Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Can ban PHP

Can ban PHP

Ratings: (0)|Views: 19|Likes:
Published by api-27344481

More info:

Published by: api-27344481 on Dec 01, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Mo\u00e2n ho\u00efc: PHP
Ba\u00f8i 1
Nh\u00f6\u00f5ng va\u00e1n \u00f1e\u00e0 ch\u00ednh se\u00f5 \u00f1\u00f6\u00f4\u00efc \u00f1e\u00e0 ca\u00e4p trong ba\u00f8i ho\u00efc:

\ue000 Gi\u00f4\u00f9i thie\u00e4u PHP
\ue000 Ca\u00e1u h\u00ecnh IIS, Apache Web Server
\ue000 Ca\u00f8i \u00f1a\u00ebt PHP.

o Ca\u00f8i \u00f1a\u00ebt PHP.
o Ca\u00e1u h\u00ecnh \u00f6\u00f9ng du\u00efng PHP
\ue000 Gi\u00f4\u00f9i thie\u00e4u PHP.

o PHP Script.
o Ghi chu\u00f9 trong PHP
o In no\u00e4i dung ba\u00e8ng PHP

1. GI\u00d4\u00d9I THIE\u00c4U PHP

PHP vie\u00e1t ta\u00e9t cu\u00fba ch\u00f6\u00f5 Personal Home Page ra \u00f1\u00f4\u00f8i na\u00eam 1994 do pha\u00f9t minh cu\u00fba Rasmus Lerdorf, va\u00f8 no\u00f9 tie\u00e1p tu\u00efc \u00f1\u00f6\u00f4\u00efc pha\u00f9t trie\u00e5n b\u00f4\u00fbi nhie\u00e0u ca\u00f9 nha\u00e2n va\u00f8 ta\u00e4p the\u00e5 kha\u00f9c, do \u00f1o\u00f9 PHP \u00f1\u00f6\u00f4\u00efc xem nh\u00f6 mo\u00e4t sa\u00fbn pha\u00e5m cu\u00fba ma\u00f5 nguo\u00e0n m\u00f4\u00fb.

PHP la\u00f8 k\u00f2ch ba\u00fbn tr\u00ecnh chu\u00fb (server script) cha\u00efy tre\u00e2n ph\u00eda server (server side) nh\u00f6
ca\u00f9ch server script kha\u00f9c (asp, jsp, cold fusion).

PHP la\u00f8 k\u00f2ch ba\u00fbn cho phe\u00f9p chu\u00f9ng ta xa\u00e2y d\u00f6\u00efng \u00f6\u00f9ng du\u00efng web tre\u00e2n ma\u00efng internet hay intranet t\u00f6\u00f4ng ta\u00f9c v\u00f4\u00f9i mo\u00efi c\u00f4 s\u00f4\u00fb d\u00f6\u00f5 lie\u00e4u nh\u00f6 mySQL, PostgreSQL, Oracle, SQL Server va\u00f8 Access.

L\u00f6u y\u00f9 ra\u00e8ng, t\u00f6\u00f8 phie\u00e2n ba\u00fbn 4.0 tr\u00f4\u00fb ve\u00e0 sau m\u00f4\u00f9i ho\u00e3 tr\u00f4\u00ef session, ngoa\u00f8i ra PHP cu\u00f5ng nh\u00f6 Perl la\u00f8 k\u00f2ch ba\u00fbng x\u00f6\u00fb ly\u00f9 chuo\u00e3i ra\u00e1t ma\u00efnh ch\u00ednh v\u00ec va\u00e4y ba\u00efn co\u00f9 the\u00e5 s\u00f6\u00fb du\u00efng PHP trong nh\u00f6\u00f5ng co\u00f9 ye\u00e2u ca\u00e0u ve\u00e0 x\u00f6\u00fb ly\u00f9 chuo\u00e3i.

2. CA\u00d8I \u00d1A\u00cbT PHP

Ca\u00f8i \u00f1a\u00ebt PHP tre\u00e2n ne\u00e0n Windows th\u00ec s\u00f6\u00fb du\u00efng php-4.0.6-Win32.zip, sau khi ca\u00f8i \u00f1a\u00ebt \u00f6\u00f9ng du\u00efng na\u00f8y tre\u00e2n \u00f1\u00f3a c\u00f6\u00f9ng se\u00f5 xua\u00e1t hie\u00e4n th\u00f6 mu\u00efc PHP, trong th\u00f6\u00ef mu\u00efc na\u00f8y se\u00f5 co\u00f9 ta\u00e4p tin php4ts.dll va\u00f8 php.exe cu\u00f8ng v\u00f4\u00f9i th\u00f6 mu\u00efc sessiondata.

Ngoa\u00f8i ra, trong th\u00f6 mu\u00efc WINDOW hoa\u00ebc WINNT se\u00f5 xua\u00e1t hie\u00e4n ta\u00e4p tin php.ini, ta\u00e4p tin na\u00f8y cho phe\u00f9p ba\u00efn ca\u00e1u h\u00ecnh cho \u00f6\u00f9ng du\u00efng PHP. Cha\u00fang ha\u00efn, khi s\u00f6\u00fb du\u00efng session, PHP ca\u00e0n mo\u00e4t n\u00f4i \u00f1e\u00e5 l\u00f6u tr\u00f6\u00f5 chu\u00f9ng, trong ta\u00e4p tin na\u00f8y ma\u00ebc \u00f1\u00f2nh la\u00f8 session.save_path = C:\PHP\sessiondata, ne\u00e1u ba\u00efn ca\u00f8i \u00f1a\u00ebt PHP v\u00f4\u00f9i th\u00f6 mu\u00efc PHP tre\u00e2n \u00f1\u00f3a D th\u00ec ba\u00efn ca\u00e0n thay \u00f1o\u00e5i \u00f1\u00f6\u00f4\u00f8ng da\u00e3n trong khai ba\u00f9o na\u00f8y.

T\u00f6\u00f4ng t\u00f6\u00ef nh\u00f6 va\u00e4y, khi co\u00f9 lo\u00e3i trong trangPHP th\u00ec lo\u00e3i th\u00f6\u00f4\u00f8ng xua\u00e1t hie\u00e4n khi trie\u00e4u go\u00efi chu\u00f9ng, \u00f1e\u00e5 che da\u00e1u ca\u00f9c lo\u00e3i na\u00f8y th\u00ec ba\u00efn ca\u00e0n khai ba\u00f9o display_errors = Off thay v\u00ec chu\u00f9ng \u00f4\u00fb tra\u00efng tha\u00f9i display_errors = On.

Ngoa\u00f8i ra, trang PHP cu\u00f5ng co\u00f9 the\u00e5 tr\u00ecnh ba\u00f8y mo\u00e4t so\u00e1 warning khi chu\u00f9ng pha\u00f9t hie\u00e4n cu\u00f9 pha\u00f9p kho\u00e2ng h\u00f4\u00efp ly\u00f9, ch\u00ednh v\u00ec va\u00e4y \u00f1e\u00e5 che da\u00e1u ca\u00f9c warning na\u00f8y th\u00ec ba\u00efn cu\u00f5ng ca\u00e0n khai ba\u00f9o tra\u00efng tha\u00f9i Off thay v\u00ec On nh\u00f6 assert.warning = Off.

3. CA\u00c1U H\u00ccNH \u00d6\u00d9NG DU\u00cfNG PHP
3.1. Ca\u00e1u h\u00ecnh IIS
Sau khi ca\u00f8i \u00f1a\u00ebt he\u00e4 \u00f1ie\u00e0u ha\u00f8nh Windows NT hay 2000 tr\u00f4\u00fb ve\u00e0 sau, ba\u00e8ng ca\u00f9ch khai ba\u00f9o

m\u00f4\u00f9i mo\u00e4t web site hay virtual site trong mo\u00e4t site \u00f1ang co\u00f9 theo ca\u00f9c b\u00f6\u00f4\u00f9c nh\u00f6 sau:
1. Ta\u00efo mo\u00e4t th\u00f6 mu\u00efc co\u00f9 te\u00e2n myPHP \u00f1e\u00e0 l\u00f6u tr\u00f6\u00f5 ca\u00f9c ta\u00e4p tin PHP
2. Kh\u00f4\u00fbi \u00f1o\u00e4ng IIS (t\u00f6\u00ef \u00f1o\u00e4ng kh\u00f4\u00fbi \u00f1o\u00e4ng ne\u00e1u Windows NT/2000)

Gia\u00f9o vie\u00e2n: Pha\u00efm H\u00f6\u00f5u Khang

3. Cho\u00efn Start | Programs | Administrative Tools | Internet Information Server 4. Ne\u00e1u ta\u00efo virtual site th\u00ec cho\u00efn Default Web Ste | R-Click | New | Virtual Site 5. Trong tr\u00f6\u00f4\u00f8ng h\u00f4\u00efp ta\u00efo m\u00f4\u00f9i Site th\u00ec Default Web Ste | R-Click | New | Site 6. Ne\u00e1u cho\u00efn tr\u00f6\u00f4\u00f8ng h\u00f4\u00efp 4 th\u00ec ba\u00efn cung ta\u00e1p die\u00e3n gia\u00fbi cu\u00fba site nh\u00f6 h\u00ecnh 1-1

H\u00ecnh 1-1: Khai ba\u00f9o die\u00e3n gia\u00fbi

7. Cho\u00efn nu\u00f9t Next va\u00f8 khai ba\u00f9o IP va\u00f8 port, trong tr\u00f6\u00f4\u00f8ng h\u00f4\u00efp ba\u00efn kho\u00e2ng s\u00f6\u00fb du\u00efng port 80 cho \u00f6\u00f9ng site kha\u00f9c th\u00ec cho\u00efn gia\u00f9 tr\u00f2 ma\u00ebc \u00f1\u00f2nh. Tuy nhie\u00e2n ne\u00e1u co\u00f9 nhie\u00e0u \u00f6\u00f9ng du\u00efng tr\u00f6\u00f4\u00f9c \u00f1o\u00f9 \u00f1a\u00f5 ca\u00e1u h\u00ecnh trong IIS th\u00ec ba\u00efn co\u00f9 the\u00e5 thay \u00f1o\u00e5i port kha\u00f9c, v\u00ed du\u00ef cho\u00efn port 85 nh\u00f6 h\u00ecnh 1-2.

H\u00ecnh 1-2: Khai ba\u00f9o IP va\u00f8 Port

L\u00f6u y\u00f9 ra\u00e8ng, port 80 la\u00f8 port chua\u00e5n \u00f1ie\u00e0u na\u00f8y co\u00f9 ngh\u00f3a la\u00f8 khi trie\u00e4u go\u00efi tre\u00e2n tr\u00ecnh
duye\u00e4t ba\u00efn kho\u00e2ng ca\u00e0n go\u00f5 port, v\u00ed du\u00ef http://localhost/. \u00d1o\u00e1i v\u00f4\u00f9i tr\u00f6\u00f4\u00f8ng h\u00f4\u00efp port kha\u00f9c th\u00ec ba\u00efn
pha\u00fbi go\u00f5 t\u00f6\u00f4ng t\u00f6\u00ef nh\u00f6 http://localhost:85/

Gia\u00f9o vie\u00e2n: Pha\u00efm H\u00f6\u00f5u Khang

8. Cho\u00efn Next, ba\u00efn cho\u00efn th\u00f6 mu\u00efc cu\u00fba \u00f6\u00f9ng du\u00efng, \u00f1o\u00e1i v\u00f4\u00f9i tr\u00f6\u00f4\u00f8ng h\u00f4\u00efp na\u00f8y chu\u00f9ng ta cho\u00efn va\u00f8o th\u00f6 mu\u00efc myPHP, cha\u00fang ha\u00efn trong tr\u00f6\u00f4\u00f8ng h\u00f4\u00efp na\u00f8y chu\u00f9ng ta cho\u00efn ht\u00f6 mu\u00efc myPHP nh\u00f6 h\u00ecnh 1-3.

H\u00ecnh 1-3: Cho\u00efn th\u00f6 mu\u00efc myPHP

9. Ke\u00e1 \u00f1e\u00e1n cho\u00efn quye\u00e0n truy ca\u00e4p web site, trong tr\u00f6\u00f4\u00f8ng h\u00f4\u00efp \u00f1ang thie\u00e1t ke\u00e1 th\u00ec ba\u00efn cho\u00efn va\u00f8o Browse. Ngoa\u00f8i ra, ne\u00e1u ba\u00efn cho phe\u00f9p ng\u00f6\u00f4\u00f8i s\u00f6\u00fb du\u00efng internet co\u00f9 the\u00e5 th\u00f6\u00efc thi ta\u00e4p tin th\u00f6\u00efc thi t\u00f6\u00f8 xa th\u00ec cho\u00efn va\u00f8o tuy\u00f8 cho\u00efn execute.

H\u00ecnh 1-4: Quye\u00e0n truy ca\u00e4p
10.Cho\u00efn Next va\u00f8 Finish, trong c\u00f6\u00fba so\u00e5 IIS xua\u00e1t hie\u00e4n \u00f6\u00f9ng du\u00efng co\u00f9 te\u00e2n myPHP (khai
ba\u00f9o trong pha\u00e0n die\u00e3n gia\u00fbi) nh\u00f6 h\u00ecnh 1-5.
Gia\u00f9o vie\u00e2n: Pha\u00efm H\u00f6\u00f5u Khang

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->