In the CI framework's systemcorerouter.php file, the line132 line begins with the following code:
is_array($routing) && isset($routing['directory']) && $this->set_directory($routing['directory']); $this->_set_routing(); // Set any routing overrides that may exist in the main index file if (is_array($routing)) { empty($routing['controller']) OR $this->set_class($routing['controller']); empty($routing['function']) OR $this->set_method($routing['function']); }
First, the first line of:
Is_array ($routing) && isset ($routing [' directory ']) && $this->set_directory ($routing [' Directory ' ]);
I'm not sure if it makes sense, so the result of a line expression (true or false) does not add judgment, what is the result (true or false)?
In addition, in the IF judgment statement, using empty to determine the two results, I also think there is no sense, if not to make a judgment, so write what ideas?
Please also advise.
Reply content:
In the CI framework's systemcorerouter.php file, the line132 line begins with the following code:
is_array($routing) && isset($routing['directory']) && $this->set_directory($routing['directory']); $this->_set_routing(); // Set any routing overrides that may exist in the main index file if (is_array($routing)) { empty($routing['controller']) OR $this->set_class($routing['controller']); empty($routing['function']) OR $this->set_method($routing['function']); }
First, the first line of:
Is_array ($routing) && isset ($routing [' directory ']) && $this->set_directory ($routing [' Directory ' ]);
I'm not sure if it makes sense, so the result of a line expression (true or false) does not add judgment, what is the result (true or false)?
In addition, in the IF judgment statement, using empty to determine the two results, I also think there is no sense, if not to make a judgment, so write what ideas?
Please also advise.
is_array($routing) && isset($routing['directory']) && $this->set_directory($routing['directory']);
&&
This symbol knows it's true + true
right.
That is, 第一个
and 第二个
must be successful to execute the third, the three are to execute the success, no this will not be executed. We can change the wording:
if (is_array($routhing) && isset($routing['directory'])) { $this->set_directory($routing['directory']);}
The idea is clear.
Why do you do this &&
?
1、因为不涉及复杂的语句2、简洁3、直观、可读性强
// && vs ||!isset($a) && $a=1;echo $a;//1isset($a) || $a =2;echo $a;//1