Sometimes I need to create PHP code for formatting arrays on the fly. one way to do this is to use `eval`. but I think of writing the generated code to a PHP file and then include it. This has many advantages to `eval`, one of them is caching of generated code. But I haven't seen such a practice in other code. I don't know if there's any problem regarding security or other things with this?

This is an example:

```
<?php

$code = '<? foreach($rows as $row) {$row["insertion"] = format($row["insertion"]);} ?>'
file_put_contents('formatter.php', $code);
include('formatter.php');

?>

```

I just want to know is it good to create a PHP file on the fly and then include it?

Or is it better to just go ahead and `eval()` the code directly, with no stored history?