Professional LAMP Linux Apache, MySQL and PHP5 Web Development phần 7

- $ ACCESS_LEVEL biến sẽ được thiết lập đến 10 tự động khi kịch bản bắt đầu, nhờ register_globals và PHP không yêu cầu thay đổi khởi tạo. May mắn thay, nó tương đối dễ dàng để tránh những cạm bẫy đó. Hãy chắc chắn rằng bạn mã với register_globals tàn tật, sử dụng hợp lý $ _GET và $ superglobals _POST, | Chapter 9 Comments As well as or instead of the authorship and licensing details mandated by PEAR other things that could go in the top comment include a synopsis of what the code it contained does. If it s a long synopsis preceding it with a one- or two-line abstract synopsizing the synopsis will help the developer who comes along later and wants to know what the file is for. PEAR also says you should use Javadoc-style comments so that they are easily translated into documentation. Opinion is just as divided on this score as on any other style issue. An argument against it is that they make the comments themselves as they appear in the source code harder to read because of all the extra formatting they attract. Another opinion when it is argued that every publicly accessible method should be commented in this way is that it encourages vapid do-nothing comments that don t actually contribute to either commentary or documentation Gets the number of elements in this Bundle. return number of elements in this Bundle. public function Count return count this- elements But the thing that any comments are supposed to do is document the intent of the code. If the code itself is well-built it will do a good job on its own of documenting what it does. What it won t document is why it was written. Naming Conventions Variables and functions with bad names are a rich source of stories that range from comedy to horror. In any application of respectable length you will need to have some consistent system for inventing names. Here are a few tips. Generic counter variables for controlling for loops should be short and sweet. Unless context provides an obvious choice for the variable then the convention is to use i first. If you then nest another loop its variable is j followed by k and then l. Typically if you need to nest your loops any deeper then you may want to reconsider what you are doing and move all but the outermost block of statements into a function. If loops aren t .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
202    78    2    25-04-2024
Đã 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.