function read_file_array($filename, $skip_empty_lines = false)
{
// Check whether the file is a normal file and check whether the file is readable
if (is_file($filename) && is_readable($filename )) {
but but #} Else {
// Query file content
Return file ($ FILENAME);
}
}
Return "This file cannot be read!"
var_dump(read_file_array('text1.txt'));
Question: Teacher Wei Xiaobao, the last line in the read_file_array function here
Why don't this behavior need to be wrapped with else()? In the previous courses, the if statement was not followed by elseif() and the return output was directly performed. Although there is no problem for the time being, it is not impossible. Is it consistent with norms or logic? ?
return jumps out of the function, so return can only be executed once in a function, so it will be fine without adding else
The last one is useless else is just a matter of efficiency and does not violate the standards and logic