Coding CommunityE-Learning Quiz of the Day: 10/10/2016



The problem here is that strpos() returns the starting position index of $str1 in $str2 (if found), otherwise it returns false. So in this example, strpos() returns 0 (which is then coerced to false when referenced in the if statement). That’s why the code doesn’t work properly.
The correct solution would be to explicitly compare the value returned by strpos() to false as follows:

Note that we used the !== operator, not just the != operator. If we use !=, we’ll be back to the problem that 0 is coerced to false when referenced in a boolean expression, so 0 != false will evaluate to false.

If you want to explore more about PHP, visit our videos section! Below are some examples:

You can also follow some of the broadcasters who program in PHP, as below:

PHP challenge coding programming quizakkadius

PHP challenge coding programming quizinkblotty

Another cool way to find out interesting things about PHP is to access our project page!

About author

About Author Dr. Michael Jurgen Garbade is the founder of LiveEdu.TV, Kyuda, Education Ecosystem. He is future Venture Capitalist, Future Politician and always on the lookout for the Next Big Challenge. Obtained Masters in business administration and physics, and a Ph.D. in finance with professional work experience in high-paced environments at Fortune 500 companies like Amazon and General Electric. Expertize: Python, PHP, Sencha Touch & C++, SEO, Finance, Strategy & E-commerce. He speaks English and German and has worked in the US, Europe, and Asia. At Education Ecosystem he is the CEO and runs business operations.
Related posts
Career DevelopmentCoding Community

Continuous Integration Vs. Continuous Deployment: How does AWS CodeBuild & AWS CodePipeline Compare?

Career DevelopmentCoding Community

Moving from Jenkins to Jenkins X: Scaling and Accelerating CI/CD

Career DevelopmentCoding Community

Top 10 Tips for Visualizing Coronavirus Data

Career DevelopmentCoding Community

AWS CodeCommit - An Alternative Version Control to GitHub