Skip to content
Snippets Groups Projects
Select Git revision
  • de933feb53c55188ce47ccf9f5e8273abf52228e
  • main default protected
2 results

inc_functions.php

Blame
  • user avatar
    Hahn Axel (hahn) authored
    de933feb
    History
    inc_functions.php 1.29 KiB
    <?php
    
    function getOutput($sPhpcode){
        global $renderAdminLTE;
        $sOut = '';
    
        eval("\$sOut=$sPhpcode;");
        return $sOut;
    }
    
    function showExample($sPhpcode){
        // global $renderAdminLTE;
        $sOut = getOutput($sPhpcode);
    
        return '
            <table class="table">
                <thead>
                    <tr>
                        <th>Source</th>
                        <th>Output</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                    <td>
                        <pre class="highlight">'.
                            str_replace(
                                ['array (', '))'], 
                                ['array (<span class="params">', '</span>))'], 
                                htmlentities($sPhpcode))
                            .'</pre>
                    </td>
                    <td>
                        '.$sOut.'<br><br>
                        <pre>'.
                            str_replace(
                                ['&gt;', '&lt;'], 
                                ['&gt;<span class="output">', '</span>&lt;'], 
                                htmlentities(str_replace([">", "</", "\n\n" ], [">\n", "\n</", "\n"], $sOut))
                            )
                            .'</pre>
                    </td>
                    </tr>
                </tbody>
            </table>
        
        ';
    }