Welcome to my series on every PHP keyword and its usage. Today’s item: abstract. The abstract keyword can be used to enforce that a class or method cannot be used directly, but must be extended. An abstract method can only be used inside of an abstract class. When a class is marked abstract, it must be extended. When a method is marked abstract, it must be overridden with the same signature.
While most browsers have responsive emulation available from their web inspector, Safari has a completely separate system available from the debug menu. If you don’t have the debug menu enabled, check the “Show Develop menu in menu bar” checkbox at the bottom of the Advanced tab in Safari’s preferences: Responsive Design Mode can be enabled by using the ^⌘R (control + command + R) shortcut, or by selecting it from the Develop menu:
Welcome to my series on every PHP keyword and its usage. Today’s item: xor. The xor (exclusive or) operator is a logical operator that will result in true if only one of its operands are true. If neither is true, or both of them are true, the result of the expression is false. Example 1 2 3 4 5 6 7 8 <?php // False $a = false xor false; $b = true xor true; // True $c = false xor true; $d = true xor false;
Welcome to my series on every PHP keyword and its usage. Today’s items: try, catch and finally. These keywords help your code to gracefully handle exceptions that would otherwise end its execution with an ugly error message. The try block includes the code that might throw an exception, while the catch block(s) handle any exceptions thrown in the try block. Simple example 1 2 3 4 5 6 7 8 9 10 <?
Welcome to my series on every PHP keyword and its usage. Today’s item: return. The return keyword ends the current scope, and optionally passes a value back to the calling scope. It can be used inside of functions/methods, and in the global scope. When used inside a function, the function will finish and the result will be passed back to the caller. When used inside the global scope, it will end the current script.