title: Tricks for shortening PHP code?
body: <p>I am looking for neat tricks that can be used to compress PHP code while working on a fun <a href="https://github.com/Xeoncross/1kb-PHP-MVC-Framework" rel="nofollow">project</a>. Let me share some of the ones I know so far.</p>
  
  <p>Using straight conditionals with no brackets</p>
  
  <pre><code>if(TRUE)yes();else no();
  </code></pre>
  
  <p>You can acquire and validate variables in one line</p>
  
  <pre><code>if(!($value=function($input)||empty($value-&gt;foo))return FALSE;
  </code></pre>
  
  <p>You can check a value (and default) using the <a href="http://www.php.net/manual/en/language.operators.comparison.php" rel="nofollow">Ternary Operator</a> in PHP 5.3</p>
  
  <pre><code>$foo = $bar?:NULL;
  </code></pre>
  
  <p>Return boolean values for conditions</p>
  
  <pre><code>return!$foo;
  </code></pre>
  
  <p>And one I place at the top of my PHP classes to protect them from direct access - straight boolean checks:</p>
  
  <pre><code>defined('BASE_DIR')||die();
  </code></pre>
  
  <p><strong>What is the most valuable PHP trick you have learned to reduce space used?</strong></p>
  
  <p><strong>Update:</strong> There seems to be some concern about how unreadable compressed code is. I concur, do not write code like this normally. However, I'm attempting to compress code into very small tidbits for fun and I want to know all the options I have to compress a function into a few dozen characters. </p>
  
  <p><strong>Next time please answer the question and don't surmise about my ignorance of best-practices.</strong></p>