natepizzle Posted June 26, 2009 Share Posted June 26, 2009 I understand '===0' means is exactly the same but i don't understand the return statement with that on the end. I saw this code snippet at http://www.jonasjohn.de/snippets/php/starts-with.htm and its dated back in 2007 so maybe its just old and not UTD with php 5. Maybe there is an implied if statement there saying return this line only if it is exactly equal to 0. Thanks for any help. [cod] function StartsWith($Haystack, $Needle){ // Recommended version, using strpos return strpos($Haystack, $Needle) === 0; } [/cod] Quote Link to comment https://forums.phpfreaks.com/topic/163810-solved-could-someone-help-me-understand-this-0/ Share on other sites More sharing options...
WolfRage Posted June 26, 2009 Share Posted June 26, 2009 You are correct it is an implied if statement, but I would consider it extreme shorthand and not considered valid syntax. Basically it will return 0 if the function evaluates to TRUE. Else it will not return anything. Quote Link to comment https://forums.phpfreaks.com/topic/163810-solved-could-someone-help-me-understand-this-0/#findComment-864314 Share on other sites More sharing options...
natepizzle Posted June 26, 2009 Author Share Posted June 26, 2009 thank you Quote Link to comment https://forums.phpfreaks.com/topic/163810-solved-could-someone-help-me-understand-this-0/#findComment-864337 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.