KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've always came away from stackoverflow answers and any reading I've done that "===" is superior to "==" because uses a more strict comparison, and you do not waste resources converting value types in order to check for a match. I may be coming at this with the wrong assumption, so I assume part of this question is, "is my assumption true?" Secondly, I'm dealing specifically with a situation where I'm getting data from a database in the form of a string "100" . The code I am comparing is this... if ($this->the_user->group == 100) //admin { Response::redirect('admin/home'); } else // other { Response::redirect('user/home'); } vs. if ( (int) $this->the_user->group === 100) //admin { Response::redirect('admin/home'); } else // other { Response::redirect('user/home'); } or even if (intval($this->the_user->group) === 100) //admin { Response::redirect('admin/home'); } else // other { Response::redirect('user/home'); } is any integrity (or performance) gained by manually casting or converting simply so you can use the identity ( '===' ) comparison?
Tags (comma-separated)
Save Edits
Cancel