[英]how to call a constant by a variable
I have a function which I use like this我有一个像这样使用的功能
$i18n_APP = new i18n($_SERVER['DOCUMENT_ROOT'].'module/'.$modid.'/lang/lang_{LANGUAGE}.ini',
$_SERVER['DOCUMENT_ROOT'].'lang/langcache/', 'en');
$i18n_APP->setPrefix('APP'.$appid);
$i18n_APP->init();
Normally I call the function by the prefix, like this通常我通过前缀调用函数,就像这样
APP($el)
Now I have to use a variable prefix, cause I use the $appid, so I can't code it like the way above.现在我必须使用一个变量前缀,因为我使用了 $appid,所以我不能像上面那样编码。
Is there any way to make it in a dynamic way maybe like this App.$appid($el)有没有什么办法可以像这个 App.$appid($el) 那样以动态方式制作它
Hope I could explain what I tried to do.希望我能解释我试图做的事情。
By the way, maybe I don't need to do it, if I find a way to "add" different languagefiles to the function.顺便说一句,如果我找到一种方法将不同的语言文件“添加”到函数中,也许我不需要这样做。 For the moment I initiate a new class for every languagefile.目前,我为每个语言文件启动了一个新类。
I find a way to solve it我找到了解决它的方法
function langtag($prefix, $value)
{
return $prefix($value);
}
and和
$moid=4;
echo langtag('APP'.$modid,$el)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.