chantown Posted September 8, 2007 Share Posted September 8, 2007 This script says this (it's a login script)... $this->username = $_SESSION['username'] = $this->userinfoarray['username']; Theres 2 equal signs.. why can't he just do $this->username = $this->userinfoarray['username']; ? Link to comment https://forums.phpfreaks.com/topic/68436-are-2-equal-signs-ok/ Share on other sites More sharing options...
cooldude832 Posted September 8, 2007 Share Posted September 8, 2007 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 More sharing options...
chantown Posted September 8, 2007 Author Share Posted September 8, 2007 No, i mean that php "statement" has 2 equal signs in it (not ==) Link to comment https://forums.phpfreaks.com/topic/68436-are-2-equal-signs-ok/#findComment-344083 Share on other sites More sharing options...
cooldude832 Posted September 8, 2007 Share Posted September 8, 2007 reallly an OOP question, but anyways I think its just saying A=B=C so A=C and B=C. Link to comment https://forums.phpfreaks.com/topic/68436-are-2-equal-signs-ok/#findComment-344084 Share on other sites More sharing options...
noidtluom Posted September 8, 2007 Share Posted September 8, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.