Skip to content

Smells Of Code Series - PHP If condition

smells of code

This my first code smell, a basic one. A friend asks me to have a look and integrate a 3rd-party service on his PHP website. He initially hired a freelance developer through a freelance platform to build his website but we all know the costs of maintenance. I found some good things like well design SQL queries but the website architecture was very bad. This code block was funny though 😄

1if (strpos($key, "contact-form-") === false) {
2}
3else {
4 ...
5}

I think you should switch the if condition..

1if (strpos($key, "contact-form-")) {
2 ...
3}
Edit me on GitHub
author @RobertoRJ
Thanks for reading my article. I am Roberto, a software developer pretending to be a writer!
Based in Gibraltar. Get in touch @RobertoRJ or email me at em.susejotrebor@tniopyrtne