PROGRAMMING

 
REMEMBERS




Last update:   29-10-2021

Function name

! Function name is not case-sensitive. Function name must not start with a number.
 
function name() {}
function Name() {}

// Fatal error: Cannot redeclare Name()

Return

! Note that since return is a language construct and not a function ... the parentheses surrounding its arguments are not required. It is common to leave them out, also PHP has less work to do in this case.
 
function A() {
    return (1);
}
    
function B() {
    return 2; // faster
}
    
echo A(); // Output: 1
echo B(); // Output: 2
... 3 lines
 

Null

! Even if you don't return a value, PHP will still cause your function to return NULL. The concept of "void" functions does not really apply to PHP.
 
function name() {}

echo name() === NULL; // Outputs: 1

Questions    
Function anonymous

        A B C D E F
🔔
1/3