TAILIEUCHUNG - Giải pháp thiết kế web động với PHP - p 6

HOW TO WRITE PHP SCRIPTS To save space, most examples in this book omit the PHP tags. You must always use them when writing your own scripts or embedding PHP into a web page. Embedding PHP in a web page PHP is an embedded language. This means that you can insert blocks of PHP code inside ordinary web pages. When somebody visits your site and requests a PHP page, the server sends it to the PHP engine, which reads the page from top to bottom looking for PHP tags. HTML passes through untouched, but whenever the PHP engine encounters a tag. If. | HOW TO WRITE PHP SCRIPTS To save space most examples in this book omit the PHP tags. You must always use them when writing your own scripts or embedding PHP into a web page. Embedding PHP in a web page PHP is an embedded language. This means that you can insert blocks of PHP code inside ordinary web pages. When somebody visits your site and requests a PHP page the server sends it to the PHP engine which reads the page from top to bottom looking for PHP tags. HTML passes through untouched but whenever the PHP engine encounters a php tag it starts processing your code and continues until it reaches the closing tag. If the PHP code produces any output it s inserted at that point. You can have multiple PHP code blocks on a page but they cannot be nested inside each other. Figure 3-1 shows a block of PHP code embedded in an ordinary web page and what it looks like in a browser and in a page source view after it has been passed through the PHP engine. The code calculates the current year checks whether it s different from a fixed year represented by startYear in line 26 of the code on the left of the figure and displays the appropriate year range in a copyright statement. As you can see from the page source view at the bottom right of the figure there s no trace of PHP in what s sent to the browser. View in browser 21 22 23 24 25 26 27 28 29 30 31 32 33 34 body hl Embedded Code hl p PHP code can be embedded directly in the body of a web page. p div id- footer p 6copy php SatartYear 2006 5thisYear date Y if 3tartYear thi3Year echo SstartYear else echo startYear - thisYearJ PHP Solutions p Embedded Code PHP page PHP engine PHP code can be embedded directly in the body of a web page. 2006-201 0 PHP Solutions Page source view Figure 3-1. The PHP code remains on the server only the output is sent to the browser. PHP doesn t always produce direct output for the browser. It may for instance check the contents of form input before sending an email message or inserting .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.