Hướng dẫn php color code list
Colors are displayed combining RED, GREEN, and BLUE light. Show Color NamesWith CSS, colors can be set by using color names: CSS Color ValuesWith CSS, colors can be specified in different ways:
RGB ColorsRGB color values are supported in all browsers. An RGB color value is specified with: rgb( RED , GREEN , BLUE ). Each parameter defines the intensity of the color as an integer between 0 and 255. For example, rgb(0,0,255) is rendered as blue, because the blue parameter is set to its highest value (255) and the others are set to 0. Example
Try it Yourself » Shades of gray are often defined using equal values for all the 3 light sources: Example
Try it Yourself » Hexadecimal ColorsHexadecimal color values are also supported in all browsers. A hexadecimal color is specified with: #RRGGBB. RR (red), GG (green) and BB (blue) are hexadecimal integers between 00 and FF specifying the intensity of the color. For example, #0000FF is displayed as blue, because the blue component is set to its highest value (FF) and the others are set to 00. Example
Try it Yourself » Shades of gray are often defined using equal values for all the 3 light sources: Example
Try it Yourself » Upper Case or Lower Case?You can use upper case or lower case letters to specify hexadecimal values. Lower case are easier to write. Upper case are easier to read. Color NamesCSS supports 140 standard color names. In the next chapter you will find a complete alphabetical list of color names with hexadecimal values:
The currentcolor KeywordThe ExampleThe border color of the following element will be blue, because the text color of the element is blue:
#myDIV { Try it Yourself » W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 1999-2022 by Refsnes Data. All Rights Reserved. Bài này sẽ giới thiệu cú pháp (syntax) và các thành phần cơ bản trong PHP. Để học tốt bài này, các bạn cần đọc lại bài Cài đặt môi trường lập trình Web PHP với XAMPP để biết cách chạy ứng dụng web PHP với XAMPP. Các file PHP chứa code PHP có đuôi mở rộng là PHP script bắt đầu với
Trong thư mục C:\xampp\htdocs\gochocit, tạo file index.php với nội dung như bên dưới.
Trong ví dụ trên, file Trong PHP, keyword (if, else, while, echo,…), class, function và user-defined function không phân biệt chữ hoa chữ thường. Nhưng tất cả tên biến (variable) thì có phân biệt chữ hoa chữ thường. Xem ví dụ bên dưới.
Kết quả
Các câu lệnh ECHO, echo, EcHo là như nhau. Nhưng các biến Chú thích (comment) sẽ không được thông dịch bởi PHP interpreter. Comment giúp diễn giải ý nghĩa của code, giúp người đọc code dễ hiểu hơn. PHP hỗ trợ 3 cách viết comment: – Comment trên một dòng với // – Comment trên một dòng với # – Comment trên nhiều dòng với /* */
3. Từ khóa (keyword) trong PHPTừ khóa (keyword) là những từ (word) được dành riêng trong PHP. Chúng ta không thể sử dụng từ khóa để đặt tên biến, tên hàm hoặc bất kỳ định danh (identifier) nào khác. Chúng được sử dụng để xác định cú pháp và cấu trúc của ngôn ngữ PHP. Trong PHP, các từ khóa không có sự phân biệt chữ hoa và chữ thường.
Ngoài ra, chúng ta còn có một số hằng số được định nghĩa trước (predefined constants).
4. Định danh (identifier) trong PHPCác biến (variable), hằng (constant), hàm (function),… trong PHP đều phải có tên gọi riêng. Các tên gọi này gọi là định danh (identifier). Khi đặt tên định danh, chúng ta phải tuân thủ các quy tắc sau: 1. Tên định danh chỉ được phép chứa các chữ cái (A-Z, a-z), chữ số (0-9) và dấu gạch dưới _. Ví dụ, 2. Ký tự đầu tiên trong tên định danh không được phép là chữ số. Ví dụ, tên định danh 3. Tên gọi không được trùng với từ khóa (keyword). 4. Không được sử dụng các ký hiệu đặc biệt như 5. Tên định danh có thể có độ dài bất kỳ. 5. Câu lệnh (statement) trong PHPKhi thực thi
PHP script, từng câu lệnh (statement) sẽ được thực thi. Mỗi câu lệnh trong PHP phải được kết thúc bởi
Kết quả
Lưu ý: Một statement có thể được viết trên 1 hoặc nhiều dòng.
|