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) {
3else {
4 ...

For readability I think you should switch the if condition..

1if (strpos($key, "contact-form-") !== false) {
2 ...
Edit me on GitHub
author @RobertoRJ
Thanks for reading my article. I am Roberto and please share your feedback below.
Based in Digital Nomad. Get in touch @RobertoRJ or email me at em.susejotrebor@tniopyrtne