Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Illegal function name

Description

This error messages appears when there is an attempt to create a closure from a function, whose name is not a valid function. Numbers, such as float and integers, are not valid function name, and yield this error. Negative numbers, and other types yield a distinct error.

Example

<?php

const Closure = (0)(...);

var_dump(Closure);

?>

Alternatives

  • Use a string, instead of a number. Check that the string is a valid name for a function or a static method.
  • Ensures that the name is a static expression, and that each element may be resolved at compile time.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See