MLNTN

Maniacal musings of a pixel perfectionist

HUMOR: How to use the same code for PHP and Javascript

Posted by Jared on December 2, 2010

I recently had to disable some forms if a certain case existed and I came up with a hilarious way to use the same code for PHP and Javascript. Sometimes, amusing myself is how I get through a day.

First the PHP:

unset($_POST);

Simple, right?

Now for the Javascript (with a little help from jQuery):

var $_POST = 'post';
function unset(type) {
  $('form[method='+type+']').bind('submit', function(){ return false; });
}
$(function(){
    unset($_POST);
});

Okay, it takes a little more effort and “unset” is a horrible function name for what it’s doing. But it’s worth it, right? Right?!

5 Responses to “HUMOR: How to use the same code for PHP and Javascript”

  1. Steve Love says:

    You need to submit this to php.js immediately. ;)

  2. huarong says:

    蛋疼的文章。。。

  3. Jared says:

    The comment above translates (via Google Translate) to “Egg pain article…”. I’m pretty sure that’s an insult. :)

  4. Jared says:

    Nice, Steve.

  5. [...] myself is how I get through a day. First the PHP: unset($_POST); Simple, right? Now… [full post] Jared MLNTN javascriptphp 0 0 0 0 0 [02 Dec [...]

Leave a Reply