CSI: PHP

"Looking at your tweets I cannot even fathom what your job is. CSI:PHP?" — @grmpyprogrammer

What Idiot Wrote This? Oh, Wait, It Was Me.

| Comments

Starting with this post, we have a new category here at CSI: PHP. It’s called ‘mea culpa’, and it’s criminal code written by yours truly.

Behold the awesome that is error(), an unholy concoction of PHP, JavaScript, and HTML. It’s the only function in a file called common.php, which makes perfect sense because shut up. Yes, this was in production use, and would dislpay a JavaScript alert with an error message whenever I remembered to use it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php // common.php

function error($msg) {
    ?>
    <html>
    <head>
    <script language="JavaScript">
    <!--
        alert("<?=$msg?>");
        history.back();
    //-->
    </script>
    </head>
    <body>
    </body>
    </html>
    <?
    exit;
}

Comments