从PHP字符串执行PHP函数

I searched on google and on stackoverflow for this but i couldn't find any results. What i want is to know if you can execute a php function from a string. Why ? I have a function that creates a table after an array. Thing is i want to, for example format a unix timestamp into a date but dynamically. Example

 'Register date' => array(
      "<?php date('h:m:i',{RegDate}); ?>"
  ),

Is it possible ? (I already have a function that converts {RegDate} to the respective row,so the only thing i need is to somehow execute the function date,if possible)

I tried eval and even just a simple echo,but every time htmls comments my php tags and they become

 <!--?php date('h:m:i',1362159376); ?-->

You can use anonymous functions for it:

'Register date' => function($regdate) {
    return date('h:m:i', $regdate);
},

Then call it like so:

call_user_func($x['Register date'], $row['date']);

Why not just use

'Register date' => array(
    date('h:m:i', RegDate))

From what I can see there's no reason to try and use variable parsing on this since date() returns a string already. If you really need to you can use the following:

'Register date' => array(
    "{date('h:m:i', RegDate)}")

The entire expression needs to be inside the {}'s of the string to execute, which is why in your example you were getting the timestamp but not the rest of the expression.

What i want is to know if you can execute a php function from a string.

Yes you can, but it seems that this is not your question. Executing a function "from string":

<?php
    call_user_func('date', 'h:m:i', RegDate);

So if "dynamically" means you want to tell the function name as well, then this is the way.

You can also pass parameters as an array:

<?php
    call_user_func_array('date', array('h:m:i', RegDate));