SlideShare une entreprise Scribd logo
1  sur  23
※轉貼請註明出處 http://sudo.tw
EricPing
http://sudo.tw
※轉貼請註明出處 http://sudo.tw
 很簡單,就是你打開瀏覽器看到的畫面!
※轉貼請註明出處 http://sudo.tw
 打開你的網頁,按右鍵→檢視網頁原始碼
 你看到的那些密密的文字就是原始碼
※轉貼請註明出處 http://sudo.tw
 是的,原始碼是公開的!
 但是你(Client端)看到的只有HTML、CSS、
JavaScript等!
(有些初學者會覺得說php也是公開的,但事實不
是這樣)
※轉貼請註明出處 http://sudo.tw
 Client端程式語言!在瀏覽器上執行的!
因為HTML、CSS無法進行數學式的運算、動態
效果!
為了減少Server端的壓力以及能與使用者產生互
動,所以JavaScript誔生了!
※轉貼請註明出處 http://sudo.tw
 打開你的記事本!將以下內容打下來,然後存
成index.html,使用瀏覽器打開!
<script>
var a=1;
var b=2;
alert(a+b);
</script>
※轉貼請註明出處 http://sudo.tw
 這時你會發現會跳出訊息,就代表成功了
※轉貼請註明出處 http://sudo.tw
按下確定後,再檢視一次原始碼,你會看到
<script>
var a=1; //宣告變數a 等於1
var b=2; //宣告變數b 等於2
alert(a+b);//跳出訊息框
</script>
※轉貼請註明出處 http://sudo.tw
 如同上述程式碼,在電腦不連上網路的情況下
也可以執行,由瀏覽器本身去執行JavaScript的
程式碼!
※轉貼請註明出處 http://sudo.tw
 JavaScript也可以做到與Server端互動這件事,
這又是另一門學問了,Ajax!在網頁不重新整
理的情況下更新資料。
※轉貼請註明出處 http://sudo.tw
使用者可以透過JavaScript告訴瀏覽器說:
 我現在要發出訊息給別人
 別人可以發訊息給我
 我現在要計算1+1(小算盤)
然後JavaScript會通知瀏覽器要執行上述的動作,
幫助使用者完成工作。
結論:JavaScript可以控制瀏覽器,管進也管出,
進行使用者與瀏覽器與Server端的資料傳輸。
※轉貼請註明出處 http://sudo.tw
 PHP是什麼?伺服器端語言!
 什麼是伺服器端語言呢?
 我們待會再來談,先看看一下簡單的HTML
※轉貼請註明出處 http://sudo.tw
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
※轉貼請註明出處 http://sudo.tw
<?php
echo "Hello World"; //印出HelloWorld
?>
※轉貼請註明出處 http://sudo.tw
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1><?php echo "Hello World";?></h1>
</body>
</html>
※轉貼請註明出處 http://sudo.tw
※轉貼請註明出處 http://sudo.tw
※轉貼請註明出處 http://sudo.tw
 因為<?php ?>裡面的內容在網頁從Server端送
出來前,就被編譯了。
 所以因此看到的就會是純HTML原始碼!
※轉貼請註明出處 http://sudo.tw
<h1>
<script>
document.write('Hello ');
</script>
<?php echo "World"?>
</h1>
※轉貼請註明出處 http://sudo.tw
<h1>
<script>
document.write('Hello ');
</script>
World
</h1>
※轉貼請註明出處 http://sudo.tw
<h1> <script>
document.write('Hello ');
</script>
Hello World
</h1>
Script裡的內容在瀏覽器執行後印出Hello
<?php echo "World";?>被編譯後送出了
※轉貼請註明出處 http://sudo.tw
接收到連線訊
息後,將php
檔即時編譯成
html後,再送
出至Client端。
※轉貼請註明出處 http://sudo.tw
 PHP是一個伺服器端語言,剛剛<?php ?>裡面
的內容在Server端進行編譯之行為,就是伺服
器端語言做的事。
 此外,PHP也可以做到將Server時間印出來,
進行登入信箱等等功能,也不會讓人看到裡面
的程式碼,動態產生出HTML。

Contenu connexe

Plus de Eric Ping

Facebook Login & Open Graph Introduction
Facebook Login & Open Graph IntroductionFacebook Login & Open Graph Introduction
Facebook Login & Open Graph IntroductionEric Ping
 
ASP.NET MVC Identity 介紹
ASP.NET MVC Identity 介紹ASP.NET MVC Identity 介紹
ASP.NET MVC Identity 介紹Eric Ping
 
Android 開發學習 (1)
Android 開發學習 (1)Android 開發學習 (1)
Android 開發學習 (1)Eric Ping
 
Android 第一次開發 心得
Android 第一次開發 心得Android 第一次開發 心得
Android 第一次開發 心得Eric Ping
 

Plus de Eric Ping (6)

Git Basics
Git BasicsGit Basics
Git Basics
 
Facebook Login & Open Graph Introduction
Facebook Login & Open Graph IntroductionFacebook Login & Open Graph Introduction
Facebook Login & Open Graph Introduction
 
ASP.NET MVC Identity 介紹
ASP.NET MVC Identity 介紹ASP.NET MVC Identity 介紹
ASP.NET MVC Identity 介紹
 
Android 開發學習 (1)
Android 開發學習 (1)Android 開發學習 (1)
Android 開發學習 (1)
 
Css3 介紹
Css3 介紹Css3 介紹
Css3 介紹
 
Android 第一次開發 心得
Android 第一次開發 心得Android 第一次開發 心得
Android 第一次開發 心得
 

什麼是PHP & JavaScript