Hey all. I have a question regarding PHP’s If shorthand. Is it possible with PHP’s If shorthand to first include a file and then create a class from that file?
Here’s what I mean:
$object = ($userpresent) ? include file; new firstclass : include different file; new otherclass;
I know the above is incorrect. But is there a way to do this with shorthand?
Thanks
No. This is the ternary operation and it will return and assign a value (in your case back to $object). Doing anything else will not work.