1.2.887. Or Die

Classic old style failed error management.

Interrupting a script will leave the application with a blank page, will make your life miserable for testing. Just don’t do that.

<?php

// In case the connexion fails, this kills the current script
mysql_connect('localhost', $user, $pass) or die();

?>

See also pg_last_error and PDO::exec.

1.2.887.1. Suggestions

  • Throw an exception

  • Trigger an error with trigger_error()

  • Use your own error mechanism

1.2.887.2. Specs

Short name

Structures/OrDie

Rulesets

All, Analyze, CE, CI-checks

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

ClearPHP

no-implied-if

Examples

Tine20, OpenConf

Available in

Entreprise Edition, Community Edition, Exakat Cloud