PHP speed: what is faster? if (isset ($foo)) OR if ($foo==true)
optimization, performance, php
Solution
With a `for` loop repeating it 10000000 times the same script took:
- `if (isset ($item))` 2.25843787193
- `if ($item_exists==true)` 6.25483512878
- `if ($item_exists===true)` 5.99481105804
So I can tell `isset` surely is faster.
Problem
I am just trying to optimize my code. I need to prefill a form with data from a database, and I need to check if the variable exist to fill the text box (I don't like the `@` error hiding). The form is really long, then I need to check multiple times if the variables exist. What is faster of the following two? - `if (isset ($item))` - `if ($item_exists==true)` Or even - `if ($item_exists===true)`