Saurabh Gandhe I am a Coder!

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!

Add comment

Leave a Reply

By Saurabh
Saurabh Gandhe I am a Coder!

Recent Posts

Categories

%d bloggers like this: