TAILIEUCHUNG - SAMS Teach Yourself PHP4 in 24 Hours phần 3

Với sự bùng nổ của hệ thống Internet, website đã trở thành rất quen thuộc với người sử dụng. Cũng chính vì thế, công nghệ thiết kế web site cũng phát triển rất mạnh và phong phú. Ngôn ngữ lập trình web PHP & MySQL là một ngôn ngữ mã nguồn mở đã khẳng định sự thành công của nó với 20% tên miền trên hệ thống Internet. | 91 13 body 14 html The script in Listing will simply output the string HELLO wrapped in an HTML H1 element. We declare a function bighello that requires no arguments. Because of this we leave the parentheses empty. bighello is a working function but not terribly useful. Listing creates a function that requires an argument and actually does something helpful with it. Listing Declaring a Function That Requires Arguments 1 html 2 head 3 title Listing title 4 head 5 body 6 php 7 function printBR txt 8 9 print txt br n 10 11 printBR This is a line 12 printBR This is a new line 13 printBR This is yet another line 14 15 body 16 html Figure A function that prints a string with an appended BR tag. 92 You can see the output from the script in Listing in Figure . The printBR function expects a string so we place the variable name txt between the parentheses when we declare the function. Whatever is passed to printBR is stored in txt. Within the body of the function we print the txt variable appending a br element and a newline character to it. Now when we want to write a line to the browser we can call printBR instead of the built-in print saving us the bother of typing the br element. Returning Values from User-Defined Functions A function can return a value using the return statement in conjunction with a value or object. return stops the execution of the function and sends the value back to the calling code. Listing creates a function that returns the sum of two numbers. Listing A Function That Returns a Value 1 html 2 head 3 title Listing title 4 head 5 body 6 php 7 function addNums firstnum secondnum 8 9 result firstnum secondnum 10 return result 11 12 print addNums 3 5 13 will print 8 14 15 body 16 html The script in Listing will print the number 8 . addNums should be called with two numeric arguments 3 and 5 in this case . These are stored in the variables firstnum and secondnum. Predictably addNums adds the numbers contained

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.