TAILIEUCHUNG - PHP and MySQL Web Development - P34

PHP and MySQL Web Development - P34: 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. | 132 Chapter 5 Reusing Code and Writing Functions Built-in functions are available to all PHP scripts but if you declare your own functions they are only available to the script s in which they were declared. It is a good idea to have one file containing your commonly used can then have a require statement in all your scripts to make your functions available. Within a function curly braces enclose the code that performs the task you require. Between these braces you can have anything that is legal elsewhere in a PHP script including function calls declarations of new variables or functions require or include statements and plain HTML. If we want to exit PHP within a function and type plain HTML we do it the same way as anywhere else in the script with a closing PHP tag followed by the following is a legal modification of the previous example and produces the same output php function my_function My function was called php Note that the PHP code is enclosed within matching opening and closing PHP tags. For most of the small code fragment examples in this book we do not show these tags. They are shown here because they are required within the example as well as above and below it. Naming Your Function The most important thing to consider when naming your functions is that the name should be short but descriptive. If your function creates a page header pageheader or page_header might be good names. A few restrictions are as follows Your function cannot have the same name as an existing function. Your function name can only contain letters digits and underscores. Your function name cannot begin with a digit. Many languages do allow you to reuse function feature is called function overloading. However PHP does not support function overloading so your function cannot have the same name as any built-in function or an existing user-defined function. Note that although every PHP script knows about all the built-in functions user-defined .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
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.