Dynamically call a static variable (array)

后端 未结 5 1221
情深已故
情深已故 2021-01-03 07:57

Here\'s my question for today. I\'m building (for fun) a simple templating engine. The basic idea is that I have a tag like this {blog:content} and I break it in a method an

5条回答
  •  太阳男子
    2021-01-03 08:21

    As with everything in PHP, there are a lot of ways to skin the same cat. I believe the most efficient way to accomplish what you want is:

    call_user_func(array($blog,$template));
    

    See: http://www.php.net/manual/en/function.call-user-func.php

提交回复
热议问题