Semantics and Readability
When you write code there are two overlying important aspects to remember. First being that your code is semantically correct (else it wont work, duh) and readability. As in the ability for your code to be read and understood by other developers and yourself in the future (you WILL forget how your code works, trust me).
I find that it is important to follow a few conventions for code readability
1) Names have meaning: make sure to name your functions and variables meaningful names. this will help, because you dont have to guess what the function ‘addTwo($val);’ does (it adds 2 to your value);
2) Meaningful Comments: comment, comment, comment. this took me a while to get into the habit of doing, I used to think “if someone wants to mess with my code, they need to be smart enough to edit it”. Only to find myself months later going back and wondering what the hell was going on. so comment! but make sure your comments are meaning full, example like ” //this function will add 2 to the passed integer”.
3) formatting: make sure you stick to a set of formatting. For myself, I write function names in camel case (ex: addTwo()); and variables are all lowercase with underscores as separators. (ex. $my_value). this just adds to the readability, and keeps your code looking nice.
Now for the real reason for this post. Here is a piece of code I’ve written. semantically it is correct, and it works just as expected. Readability wise, there is none. Hell, I almost went crazy just trying to write it. See if you can figure out what it does.
<!--?php define('_',true); define('__','chr'); define('___','strlen'); define('____','hexdec'); function _______($_){ for($__=(_-_);$__<________(___,$_)-_;$__+=(_+_)){ $___.=________(__,________(____,$_[$__].$_[$__+_])); } return $___; } function ________($_,$__){ return $_($__);} $__=_+_; $___=$__+_; $____=$__*$___; $_____=_______(($__*$__).$___); $______=_______(($____-$__).$____); $_ =$____.($____+$__).$____.($__+$___).$____.$_____; $_.=$____.$_____.$____.$______.$__.(_-_).($____+_).($____+_); $_.=$____.$______.($____+_).$__.$____.$_____.$____.($____-$__); echo ________('_______',$_); ?-->

