PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

PHP 能做些什麼﹖> <入門
Last updated: Sun, 25 Nov 2007

view this page in

簡介

Table of Contents

PHP 是甚麼?

PHP ("PHP: Hypertext Preprocessor" 的首字母縮略詞) 是一種被廣泛使用、多用途的開放源碼腳本語言,特別適合於網頁的開發,並可內嵌入 HTML 中。

一個簡單的答案,但到底是什麼意思呢﹖舉個例子:

Example#1 一個簡單的例子

<html>
    <head>
        <title>Example</title>
    </head>
    <body>

        <?php 
        
echo "Hi, I'm a PHP script!"
        
?>

    </body>
</html>

請留意上述例子和其他語言如 Perl 或 C 所編寫的腳本之間的分別 -- 與其使用大量的指令來輸出 HTML,我們寫了一個內嵌了代碼的 HTML 腳本來做某些事〈以上述例子來說,輸出一行文字〉。PHP 代碼包含在特殊的開始和結束標記,讓您可以隨時進出“PHP 模式”。

和 Java Script 之類的用戶端語言不同的是,PHP 的代碼是在伺服器端執行。如果您的伺服器中有一個和上述例子中類似的腳本,用戶看到的將只是執行後的輸出,而無法知道該腳本的代碼內容。您甚至可以設定您的網頁伺服器用 PHP 來處理所有的 HTML 檔案。這樣一來,用戶也就無法知道您究竟在伺服器端做了些什麼。

對新手來說,PHP 是非常容易上手的,而對專業的程式員來說,它又提供了許多進階的功能。當您看到 PHP 長長的功能清單時,千萬不要感到害怕。您甚至可以在很短的時間內學會編寫一些簡單的腳本呢!

雖然 PHP 的開發是以執行伺服器端的腳本程式為主,但它實際上的功能卻遠超於此。後面的 PHP 能做些什麼?章節將更深入的為您介紹。



PHP 能做些什麼﹖> <入門
Last updated: Sun, 25 Nov 2007
 
add a note add a note User Contributed Notes
簡介
nostamar $AT$ g mail
30-Jan-2008 08:06
here is a "server-php >> html >> browser" process illustration:
http://www.lastown.com/forum/viewtopic.php?t=533

it shows the basic steps; first php code is parsed at server into html; then sent to browser, that understands html tags and renders them to the display the webpage, there's also some quick overview about the process.. worths taking a look at
winks716
19-Aug-2007 10:48
before html runs to show a webpage, php code runs first on web server.

so, when there lines as follow:

<table>
<tr>
<td>
  <?php
   
echo "php runs first!";
 
?>
</td>
</tr>
</table>

the first step is to run php code, we get:

<table>
<tr>
<td>
php runs first
</td>
</tr>
</table>

then, code is sent to browser, and we see somthing~
george dot langley at shaw dot ca
19-Jul-2007 08:02
"the code is executed on the server"

This is an important concept for the first-time PHP programmer to understand, so that when you get into string formatting later on, you understand the difference between formatting the on-screen content (as parsed by your browser) and formatting the HTML code (as returned by the server).
For example "/n" starts a new line in the HTML code, and its results are only seen if you look at the "source HTML". It is NOT the same as <br>!

PHP 能做些什麼﹖> <入門
Last updated: Sun, 25 Nov 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites