PHP 5/MySQL Programming- P21

PHP 5/MySQL Programming- P21:computer programming has often been seen as a difficult and arcane skill. Programming languages are difficult and complicated, out of the typical person’s reach. However, the advent of the World Wide Web has changed that to some extent. It’s reasonably easy to build and post a Web page for the entire world to see. The language of the Web is reasonably simple, and numerous applications are available to assist in the preparation of static pages | 78 PHP 5 MySQL Programming for the Absolute Beginner FIGURE This song has a straightforward pattern verse chorus verse chorus. html head title This Old Man title head body h1 This Old Man h1 h3 Demonstrates use of functions h3 verse1 chorus verse2 chorus function verse1 print HERE This old man he played 1 br He played knick-knack on my thumb br br HERE end verse1 function verse2 print HERE 79 This old man he played 2 br He played knick-knack on my shoe br br HERE end versel function chorus print HERE .with a knick-knack br paddy-whack br give a dog a bone br this old man came rolling home br br br HERE end chorus body html Careful examination of this code shows how it works. The main part of the program is extremely simple verse1 chorus verse2 chorus Creating New Functions The This Old Man code appears to have some new PHP functions. I called the verse1 function then the chorus function and so on. These new functions weren t shipped with PHP. Instead I made them as part of the page. You can take a set of instructions and store them with a name. This essentially builds a new temporary command in PHP so you can combine simple commands to do complex things. Building a function is simple. Use the keyword function followed by the function s name and a set of parentheses. Keep the parentheses empty for now you learn how to use this feature in the next section. Use a pair of braces to combine a series of code lines into one function. Don t forget the right brace to end the function definition. It s smart to indent everything between the beginning and end of a function. Chapter 3 Controlling Your Code ith Conditions and Functions 80 PHP 5 MySQL Programming for the Absolute Beginner When you look at my code you note there s one line I never indent the HERE token used for multi-line strings. The word HERE acts like a closing quotation mark and must be all the way to the left side of the screen so it can t be indented. You can use any function name you like. Careful .

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