Accepted project code-php Tutorial

Source: Internet
Author: User
The code for the accepted project code is as follows:
$str .= $ok ? "\033[0;32;40m OK \033[0m " : "\033[0;31;40m ERROR \033[0m ";


What does this writing mean and what do you want to do?


Reply to discussion (solution)

? : This is an operator. it is a whole, called a conditional operator. it works similar to the if else statement max = (a> B )? A: B; equivalent to if (a> B) {max = a;} else {max = B ;}

? : Ternary operator

$ Str. = $ OK? "\ 033 [0; 32; 40 m OK \ 033 [0 m": "\ 033 [0; 31; 40 m ERROR \ 033 [0 m ";
Equivalent
If ($ OK ){
$ Str. = "\ 033 [0; 32; 40 m OK \ 033 [0 m ";
} Else {
$ Str. = "\ 033 [0; 31; 40 m ERROR \ 033 [0 m ";
}

\ 033 10 in decimal 27, ASCII name Esc, generally used as the device control command leading

Https://code.google.com/p/conemu-maximus5/wiki/AnsiEscapeCodes
AnsiEscapeCodes is introduced in detail, mainly responsible for terminal output.

30 m Black (foreground color)
31 m red (foreground)
32 m Green (foreground)
33 m yellow (foreground)
34 m blue (foreground)
35 m purple (foreground)
36 m dark green (foreground)
37 m White (foreground)
40 m Black (background color)
41 m red (background color)
42 m green (background color)

In general, it is the place where the content is hit, and then view it in linux, there will be a color, highlight and other prompts.

For example, logs can be used in this way. it is convenient to analyze logs and view logs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.