title: PHP: Elegant way to avoid division by zero
body: <p>Much like this site, my current project has reputation and in the script that I'm working on I need to calculate the ratio between two users' reputations.</p>
  
  <pre><code>$attacker-&gt;ratio = $defender-&gt;rep / $attacker-&gt;rep;
  $defender-&gt;ratio = $attacker-&gt;rep / $defender-&gt;rep;
  </code></pre>
  
  <p>In doing so I may occasionally end up with the divisor's reputation being 0, which sucks!</p>
  
  <p>Obviously I can add a couple of checks, but I was wondering if a prettier solution hasn't been invented, something like <code>@</code> infront, but I know that's not a good idea..</p>