public static function error(string $str)
    {
        // Reloads current page with the same error, prevent endless loop
        if (SELF === REF) {
            throw new \RuntimeException('Looping references');
        }

        if (IS_AJAX_REQUEST) {
            // Return as string for ajax response
            echo $str;
        } else {
            // Run as Javascript alert
            ?>
            <script type="text/javascript">alert('<?= $str ?>');
                if (history.length) {
                    // Go back
                    history.back();
                }
                // Reload page
                window.location = '<?= REF ?>'
            </script>
            <?php
        }
        exit;
    }
public static function error(string $str)
    {
        // Reloads current page with the same error, prevent endless loop
        if (SELF === REF) {
            throw new \RuntimeException('Looping references');
        }

        if (IS_AJAX_REQUEST) {
            // Return as string for ajax response
            echo $str;
        } else {
            // Run as Javascript alert
            ?>
            <script type="text/javascript">alert('<?= $str ?>');
                if (history.length) {
                    // Go back
                    history.back();
                }
                // Reload page
                window.location = '<?= REF ?>'
            </script>
            <?php
        }
        exit;
    }
public static function error ( string $ str ) { // Reloads current page with the same error, prevent endless loop if ( SELF === REF ) { throw new \ RuntimeException ( 'Looping references' ) ; } if ( IS_AJAX_REQUEST ) { // Return as string for ajax response echo $ str ; } else { // Run as Javascript alert ?>
            <script type="text/javascript">alert('<?= $ str ?>');
                if (history.length) {
                    // Go back
                    history.back();
                }
                // Reload page
                window.location = '<?= REF ?>'
            </script>
            <?php } exit ; }
Shows Javascript error alert

@param string $str

@throws \RuntimeException
Shows Javascript error alert