PHP and MySQL Web Development - P11

PHP and MySQL Web Development - P11: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | Embedding PHP in HTML 17 ASP style echo p Order processed. p This style of tag is the same as used in Active Server Pages ASP . It can be used if you have enabled the asp_tags configuration might want to use this style of tag if you are using an editor that is geared toward ASP or if you already program in ASP. PHP Statements We tell the PHP interpreter what to do by having PHP statements between our opening and closing tags. In this example we used only one type of statement echo p Order processed. p As you have probably guessed using the echo construct has a very simple result it prints or echoes the string passed to it to the browser. In Figure you can see the result is that the text Order processed. appears in the browser window. You will notice that a semicolon appears at the end of the echo statement. This is used to separate statements in PHP much like a period is used to separate sentences in English. If you have programmed in C or Java before you will be familiar with using the semicolon in this way. Leaving the semicolon off is a common syntax error that is easily made. However it s equally easy to find and to correct. Whitespace Spacing characters such as new lines carriage returns spaces and tabs are known as whitespace. As you probably already know browsers ignore whitespace in HTML. So does the PHP engine. Consider these two HTML fragments h1 Welcome to Bob s Auto Parts h1 p What would you like to order today p and h1 Welcome to Bob s Auto Parts h1 p What would you like to order today p These two snippets of HTML code produce identical output because they appear the same to the browser. However you can and are encouraged to use whitespace in your HTML as an aid to humans to enhance the readability of your HTML code. The same is true for PHP. There is no need to have any whitespace between PHP statements but it makes the code easier to read if we put each statement on a separate line. For example echo hello echo world 18 Chapter 1 PHP .

Không thể tạo bản xem trước, hãy bấm tải xuống
Đã 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.