Saurabh Gandhe I bring your ideas to life!

There’s a better way for if($var == 5). It’s ..

T

Ever wandered which one is correct?

if($var ==5) or if (5==$var)?

Why?

Although, you might see a warning in your IDE, it’s unlikely you will get any error for saying if($var = 5) , but if you have a habit of using the other way, you will get an error for assigning variable to constant.

<?php

What you use

if($var == 5){}

What you should use

if(5==$var){}

Why you should follow me ?

because, you may do this > if($var=5){}

and only this will generate error > if(5=$var){}

Happy Coding!

By Saurabh
Saurabh Gandhe I bring your ideas to life!

Contact Hands-on DevOps with Azure/AWS Experience

Recent Posts

Categories