KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Background: Suppose I have the following obviously-incorrect PHP: try{ $vtest = ''; print(array_pop($vtest)); }catch(Exception $exx){} For it to work with array_pop, $vtest should obviously be an array, not a string. Nevertheless, when I run this code the Warning is exhibited. I don't want that, I just want the code to fail silently. Question: Is there something special about PHP try-catch compared to other languages that cause this not to work? Disclaimer: Just for reference, it is true there are other ways to handle this situation in PHP, but these are undesirable. The goal here is to avoid: The "at-sign" trick: $vtest = ''; print(@array_pop($vtest)); // <-- would like to avoid this Type Casting: $vtest = ''; $vtest = (array)$vtest; print(array_pop($vtest));
Tags (comma-separated)
Save Edits
Cancel