How to call a constant as a function name?

This works since PHP 7.0. The only things is that you have to use more expressive syntax, so that PHP knows you mean to execute myfunc instead of func.

<?php
function myfunc(){ echo 'works'; }
define('func', 'myfunc');

(func)();

Try this online: https://3v4l.org/fsGmo

The problem with PHP is that constants and identifiers are expressed as the same thing in the tokenizer. See online how this syntax is tokenized by PHP

When you use parentheses to change precedence of operations on the constant, you tell PHP to first parse the constant and use its value to execute the function. Otherwise PHP will think that func is the name of your function.