Jump to content

Are 2 equal signs ok?


chantown

Recommended Posts

There are 3 different php operators using equal signs. 

 

$var = "This" sets something equal to something else as in value

if($var == "This") is a comparasion between the values, does not care about case/var type only that their output = the same

example

$var1 = 1;

$var2 = "1";

$var1 == $var2; //This is true even though on is numeric one is a string

 

Then there is === which is like == but checks for var type and case

Link to comment
https://forums.phpfreaks.com/topic/68436-are-2-equal-signs-ok/#findComment-344081
Share on other sites

It is correct.

 

Basically he wanted to set those $this->var in the Class all the same value, as well as the _SESSION.

 

For example instead of doing:

 

<?php $var1=1; $var2=1; $var3=1; ?>

 

You can just do:

 

<?php $var1=$var2=$var3=1; ?>

 

Sorry for the lack of neatness in PHP coding ;) I'm not normally like that unless I'm giving a quick example.

Link to comment
https://forums.phpfreaks.com/topic/68436-are-2-equal-signs-ok/#findComment-344204
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.