Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Zend PHP Certification Study Guide- P3: Hãy thẳng thừng, Giả sử bạn đang thuê một ai đó để giám sát hệ thống và PHP của bạn có nó thu hẹp xuống để hai ứng cử viên. Một trong những ứng cử viên nói, "Oh yeah, tôi biết tất cả về PHP." Các ứng cử viên khác nói, "Oh yeah, tôi biết tất cả về PHP, tôi đã được thông qua kỳ thi chứng chỉ Zend." câu hỏi tiếp theo của bạn có thể sẽ là "Zend Chứng nhận là gì?" Và các ứng viên nói, "Một công ty chuyên về. | 24 Chapter 1 The Basics of PHP default echo I don t know what to do break When the interpreter encounters the switch keyword it evaluates the expression that follows it and then compares the resulting value with each of the individual case conditions. If a match is found the code is executed until the keyword break or the end of the switch code block is found whichever comes first. If no match is found and the default code block is present its contents are executed. Note that the presence of the break statement is essential if it is not present the interpreter will continue to execute code in to the next case or default code block which often but not always isn t what you want to happen.You can actually turn this behavior to your advantage to simulate a logical or operation for example this code php if a 1 II a 2 echo test one else echo test two Could be rewritten as follows php switch a case 1 case 2 echo test one break default echo test two break Iteration and Loops 25 Once inside the switch statement a value of 1 or 2 will cause the same actions to take place. Iteration and Loops Scripts are often used to perform repetitive tasks. This means that it is sometimes necessary to cause a script to execute the same instructions for a number of times that might or might not be known ahead of time. PHP provides a number of control structures that can be used for this purpose. The while Structure A while statement executes a code block until a condition is set php a 10 while a 100 a Clearly you can use a condition that can never be satisfied in which case you ll end up with an infinite loop. Infinite loops are usually not a good thing but because PHP provides the proper mechanism for interrupting the loop at any point they can also be useful. Consider the following php a 10 b 50 while true a if a 100 b if b 50 break 26 Chapter 1 The Basics of PHP In this script the true condition is always satisfied and therefore the interpreter will be more than happy to go on repeating