Conditions | 4 |
Paths | 1 |
Total Lines | 27 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
7 | function phpInclude() { |
||
8 | /** |
||
9 | * @param string the template path |
||
10 | * @param array the template vars |
||
11 | */ |
||
12 | $inc = function() { |
||
13 | ob_start(); |
||
14 | extract(func_get_arg(1)); |
||
|
|||
15 | include func_get_arg(0); |
||
16 | return ob_get_clean(); |
||
17 | }; |
||
18 | |||
19 | return function(...$args) use ($inc) { |
||
20 | $cur_level = ob_get_level(); |
||
21 | try { |
||
22 | return $inc(...$args); |
||
23 | } catch (\Exception $e) {} |
||
24 | catch (\Throwable $e) {} |
||
25 | |||
26 | // clean the ob stack |
||
27 | while (ob_get_level() > $cur_level) { |
||
28 | ob_end_clean(); |
||
29 | } |
||
30 | |||
31 | throw $e; |
||
32 | }; |
||
33 | } |
||
34 | |||
54 |