| 1 | <?php |
||
| 7 | class XFrameOptions extends Header |
||
| 8 | { |
||
| 9 | |||
| 10 | const TYPE = 'X-Frame-Options'; |
||
| 11 | const OPTIONS_DENY = 'Deny'; |
||
| 12 | const OPTIONS_SAMEORIGIN = 'Sameorigin'; |
||
| 13 | const OPTIONS_ALLOW_FROM = 'ALLOW_FROM'; |
||
| 14 | const OPTIONS_ALLOW_FROM_URI_DEFAULT = '*'; |
||
| 15 | |||
| 16 | private $options = self::OPTIONS_DENY; |
||
| 17 | private $uri = self::OPTIONS_DENY; |
||
| 18 | |||
| 19 | |||
| 20 | /** |
||
| 21 | * XFrameOptions constructor. |
||
| 22 | * @param $options |
||
| 23 | * @param array $uri |
||
| 24 | */ |
||
| 25 | public function __construct($options, $uri = array()) |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Value returned in the header |
||
| 33 | * @return string |
||
| 34 | */ |
||
| 35 | 2 | public function getValue() |
|
| 49 | |||
| 50 | /** |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | public function getOptions() |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @param string $options |
||
| 60 | * @return $this |
||
| 61 | */ |
||
| 62 | public function setOptions($options) |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @return array |
||
| 70 | */ |
||
| 71 | public function getUri() |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @param array $uri |
||
| 81 | * @return $this |
||
| 82 | */ |
||
| 83 | public function setUri($uri) |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Type for the header. Can be used to determine header to send |
||
| 91 | * @return string |
||
| 92 | */ |
||
| 93 | public function getType() |
||
| 97 | } |
||
| 98 |
PHP has two types of connecting operators (logical operators, and boolean operators):
and&&or||The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like
&&, or||.Let’s take a look at a few examples:
Logical Operators are used for Control-Flow
One case where you explicitly want to use logical operators is for control-flow such as this:
Since
dieintroduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined withthrowat this point:These limitations lead to logical operators rarely being of use in current PHP code.