What does the continuous use of "equal sign" mean? The following is a piece of code in dedecms:
$dsql=$db=new DedeSql(FALSE)
A "=" is a value assignment,
What does this method mean?
Reply to discussion (solution)
Assign values at the same time
$ A = $ B = 1;
Equivalent
$ A = 1;
$ B = 1;
However, note that
$ Dsql = $ db = new DedeSql (FALSE)
Not equivalent
$ Dsql = new DedeSql (FALSE );
$ Db = new DedeSql (FALSE );
The former is that two variables are the same instance.
The latter is an instance for each of the two variables.
I have never used it like this.
Assign values at the same time
$ A = $ B = 1;
Equivalent
$ A = 1;
$ B = 1;
However, note that
$ Dsql = $ db = new DedeSql (FALSE)
Not equivalent
$ Dsql = new DedeSql (FALSE );
$ Db = new DedeSql (FALSE );
The former is that two variables are the same instance.
The latter is an instance for each of the two variables.
...... Continuous value assignment. if the right side of the equal sign is an instantiation class, the variable value on the left side of the equal sign is the same instance, right?
This kind of thing requires not memory, but practice.
class T { public $v = 1;}$a = $b = new T;echo $a->v, ' ', $b->v; //1 1$b->v = 'a';echo $a->v, ' ', $b->v;//a a