is there any way i can mimic javascripts loose variable handling in php? for example, in php i have to write
$instituteID = ( isset( $p['regInstituteName'] ) && isset( $p['regInstituteName']['ID'] ) ) ? $p['regInstituteName']['ID'] : null;
whereas in javascript this would condense to
instituteID = p.regInstituteName && p.regInstituteName.id || null;
doesnt seem like THAT much of a difference but it adds up
Basically.. no. There have been some proposals in the past, but they have been rejected.
Edit: You can optimize it in the case you are happy throwing E_NOTICE
errors. But I'd recommend against that.
You only need one isset
with your case.
Because if $p['regInstituteName']['ID']
is set, then $p['regInstituteName']
is always set.
$instituteID = isset($p['regInstituteName']['ID']) ? $p['regInstituteName']['ID'] : null;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With