Hiding a block based on code
The best (IMHO) way is to implement hook_block_list_alter() in a custom module and unset specific blocks when you need to. Advantages are:


No PHP code in your database, so your alterations can be managed in a version control system
No hacking in the theme layer, so the alterations will remain when you switch themes
Better performance because the block is removed from the list before it is rendered


Drupal core also uses this hook to hide blocks: block.module itself implements hook_block_list_alter to apply the default block visibility settings.