When we start our journey with programming, we don't really think about coding styles and best practices. We just copy style of our teachers/mentor...
For further actions, you may consider blocking this person and/or reporting abuse
The first code example is missing a closing parenthesis.
There is one good reason to not use the ternary operator too heavily: Debugging. If you know the code works, the ternary operator can certainly optimize its visual appearance, but it is hard to set a breakpoint or do an echo inside a ternary operator.
The single greatest tips/tricks for PHP I can give are to avoid being function call heavy and to use built-in keywords as much as possible. Function calls in PHP, whether in PHP core or PHP userland, are expensive and slow. The same is true of all interpreted languages like Javascript, Python, Ruby, etc. - not just PHP. Obviously, you'll want to actually accomplish real work and therefore need to call various functions to accomplish that work. However, doing the same thing in pure PHP userland that a built-in function already does is going to be many times slower than just calling the built-in function. So don't run out and re-implement PHP core functions within PHP userland.
As to keywords:
php.net/manual/en/tokens.php
isset()andempty()are commonly used keywords that act like functions that have their own engine-level tokens (T_ISSET and T_EMPTY respectively). That is, they are built right into the core Zend engine instead of being separate function calls. As a result, they are many times faster than calling a normal function in PHP.I see, typos should be fixed now
one of the things that i always liked about php is, as a language, it was never afraid of just stealing the good bits from other languages; jave, perl, c. for instance, pattern matching is lifted straight from scala's pattern matching.