What are the PHP operators “?” and “:” called and what do they do?

前端 未结 10 1787

What are the ? and : operators in PHP?

For example:

(($request_type == \'SSL\') ? HTTPS_SERVER : HTTP_SERVER)
10条回答
  •  面向向阳花
    2020-11-22 05:10

    That's basically a fancy way of writing an if-else statement. Some say it's easier to read, some say not.

    Ternary operator at Wikipedia

提交回复
热议问题