PHP cheatsheet

This post is for PHP stuff that I needed to use, but couldn’t easily find on the web

‘pass’ in PHP

Maybe it’s bad to start using conventions from other languages, but I find that sometimes the code is more readable if you write an if statement so that nothing happens if the conditon is true and then put the code that will get run often in the else block.  In python, if you don’t want anything to happen in a block, you use the pass statement.  In PHP, you can just leave the block empty:


if ( $condition == true) {
// do nothing. note that other than the comment
// there are no statements in this block
}
else {
// do stuff

}