In javascript I can pass an object literal to an object as a parameter and if a value does not exist I can refer to a default value by coding the following;
this.title = params.title || false;
Is there a similar way to do this with PHP?
I am new to PHP and I can't seem to find an answer and if there is not an easy solution like javascript has, it seems pure crazy to me!!
Is the best way in PHP to use a ternary operator with a function call?
isset($params['title']) ? $params['title'] : false;
Thanks
Ternaryis the best way. No such functionality in PHP. It's another one of those unnaturalJSthings...||(akaOR) should be abool. Like this. It is inC/C++, where real programming happens.||is a very interesting operator which enables very interesting code; it's not any less "real" than a traditional boolean||.