Kevin Kevin - 16 days ago 6
PHP Question

Can I have a function with the same name in PHP

Can I have a function with the same name do multiple things.

e.g

function name () {
echo "this";
}

function name () {
echo "that";
}

name();


so the same function doing multiple tasks.

Answer

No, this is not possible, and will yield

Fatal error: Cannot redeclare name() (previously declared in ...) in php shell code on line ...