如何添加这种功能...
__("go")
内部:
<<<_END
...无需在定界符之前声明变量?
实在是太费时间了。
我希望我的heredoc可以读取这样的函数 __("go")
无需将它们放入外部变量中。
感谢您的帮助。
最佳答案
我想你可以为此屠宰魔法方法:
class Magic
{
public function __call($method, $args) {
// would seriously recommend checking whether `$method` exists :)
return call_user_func_array($method, $args);
}
}
$magic = new Magic;
$str = <<<EOM
Hello this should give the {$magic->time()}.
EOM;
关于php - 定界符和特殊字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17109639/