Hướng dẫn dùng yeld means trong PHP
Với người mới bắt đầu học lập trình, ngôn ngữ được ưu tiên hàng đầu và gần như bắt buộc đó chính là C/C++. Tuy nhiên, có nhiều IDE hỗ trợ cho ngôn ngữ này, với nhiều ưu, nhược điểm khác nhau sẽ khiến bạn gặp bối rối khi lựa chọn. Nếu cảm thấy bộ công cụ Visual Studio của Microsoft quá cồng kềnh và đặc biệt, phải trả phí nếu bạn không có tài khoản DreamSpark, thì hãy thử lựa chọn một IDE nhỏ gọn hơn nhưng không kém phần hiệu quả, đó chính là Dev-C++. Hướng dẫn Dev-C++ căn bản là bài viết thích hợp cho người mới bắt đầu. Đầu tiên, bạn truy cập vào địa chỉ sau để tải về Dev-C++ và cài đặt vào máy tính của mình: https://sourceforge.net/projects/orwelldevcpp/files/latest/download. Gói cài đặt và dung lượng chiếm dụng ổ đĩa chưa tới 100MB, nên bạn không phải lo lắng về vấn đề dung lượng. Bạn lưu ý là nên tải phiên bản mới nhất để phần mềm cập nhật trình biên dịch mã nguồn mới nhất, giúp ta hạn chế lỗi khi viết code hơn. Giao diện của chương trình sau khi cài đặt và khởi động lên lần đầu. Ta sẽ thấy nó đơn giản hơn rất nhiều so với bộ Visual Studio. Để thử sử dụng và thấy được điểm khác biệt về tính tiện dụng của nó, ta thử viết một chương trình nhỏ minh họa. Bạn chọn vào trình đơn File, chọn tiếp New. Bước tiếp theo này, ta có hai hướng lựa chọn là Source File hoặc Project… Nếu bạn chọn Source File, thì phần mềm sẽ tạo ra một file blank (tập tin tương đương Empty File trong Visual Studio). Lựa chọn này thích hợp cho người mới bắt đầu lập trình, khi mà phải viết từng dòng code kể cả phần khai báo thư viện với lệnh include ở đầu chương trình. Lựa chọn Project… thì sẽ tiện dụng hơn, nó sẽ cho bạn một menu để lựa chọn loại và kiểu chương trình bạn viết ra là ở dạng Console hay Windows App hoặc các dạng khác. Và như vậy, nếu bạn tạo ra một Project cho mình, thì mỗi lần thêm một file chứa code mới, nó sẽ tự động gom nhóm lại và bỏ trong duy nhất Project đó mà thôi, chứ không để rời rạc. Tính năng này thuận tiện cho việc chia sẻ, trao đổi code không phải tìm kiếm từ nhiều nơi trong máy tính. Trong bài viết này, ta sẽ minh họa với lệnh New -> Source File cho người bắt đầu. Sau khi đã viết thử một chương trình nhỏ đơn giản, ta tiếp tục vào menu Execute, chọn Compile và chương trình nếu biên dịch không có lỗi thì sẽ trả về kết quả như sau: Tiếp tục, ta vào menu Execute và chọn Run. Do chương trình ta viết ở dạng Console, nên chắc chắn khi Run, nó sẽ không hiển thị gì khác ngoài một màn hình đen nhỏ nháy lên rất nhanh rồi tắt. Nếu muốn kiểm tra thử, bạn phải mở cmd của máy tính lên, chuyển về thư mục gốc là C:\ Sau đó, ta gõ tên chương trình đã đặt khi nãy vào, nhấn Tab cho đến khi cmd chuyển sang file dạng tên_file.exe thì hãy nhấn Enter. Như vậy, bạn đã biết được cách biên dịch và kiểm thử một chương trình viết bằng Dev-C++ rồi. VÕ TÌNH THƯƠNG Anonymous ¶ 18 years ago of course this should be clear, but i think it has to be mentioned espacially: AND is not the same like && for example: && $b || $c; ?> the second 'cause || has got a higher priority than and, but less than && of course, using always [ && and || ] or [ AND and OR ] would be okay, but than you should at least respect the following: = $b && $c; ?> maybe usefull for some tricky coding and helpfull to prevent bugs :D greetz, Warhog anisgazig at gmail dot com ¶ 1 year ago Operator are used to perform operation. Operator are mainly divided by three groups. Operator are mainly divided by three groups that are totally seventeen types. 2.Assignment Operator 3.Array Operator 4.Bitwise Operator 5.Comparison Operator 6.Execution Operator 7.Error Control Operator 8.Incrementing/Decrementing Operator 9.Logical Operator 10.string Operator 11.Type Operator 12.Ternary or Conditional operator 13.Null Coalescing Operator 14.Clone new
Operator 15.yield from Operator yield from = yield from 16.yield Operator 17.print Operator yasuo_ohgaki at hotmail dot com ¶ 21 years ago Other Language books' operator precedence section usually include "(" and ")" - with exception of a Perl book that I have. (In PHP "{" and "}" should also be considered also). However, PHP Manual is not listed "(" and ")" in precedence list. It looks like "(" and ")" has higher precedence as it should be. Note: If you write following code, you would need "()" to get expected value. $bar = true; phpnet dot 20 dot dpnsubs at xoxy dot net ¶ 14 years ago Note that in php the ternary operator ?: has a left associativity unlike in C and C++ where it has right associativity. You cannot write code like this (as you may have accustomed to in C/C++): $a = 2; $a = 2; echo ( $a == 1 ? 'one' :($a == 2 ? 'two' : ($a == 3 ? 'three' : ($a == 4 ? 'four' : 'other') ) ) ); echo "\n"; //prints 'two' ?> ivijan dot stefan at gmail dot com ¶ 3 years ago If you use "AND" and "OR", you'll eventually get tripped up by something like this: $this_one = true; If you said "false" ...it's wrong! "$truthiness" above has the value "true". Why? "=" has a higher precedence than "and". The addition of parentheses to show the implicit order makes this clearer: ($truthiness = $this_one) and $that; This also works to get the correct value, as parentheses have higher precedence than "=": $truthiness = ($this_one and $that); anisgazig at gmail dot com ¶ 1 year ago A variable is a container that contain different types of data and the operator operates a variable correctly. me at robrosenbaum dot com ¶ 15 years ago The scope resolution operator ::, which is missing from the list above, has higher precedence than [], and lower precedence than 'new'. This means that self::$array[$var] works as expected. rick at nomorespam dot fourfront dot ltd dot uk ¶ 17 years ago A quick note to any C developers out there, assignment expressions are not interpreted as you may expect - take the following code ;- $a=array(1,2,3); Under a C compiler the result is;- It would appear that in php the increment in the left side of the assignment is processed prior to processing the right side of the assignment, whereas in C, neither increment occurs until after the assignment. |