title: Can i define "" (Nothing) as "0" in Throughout The WHOLE PHP Script?
body: <p>In my script i currently use 100+ lines of code defining nothing as "0"</p>
  
  <p>I.e</p>
  
  <pre><code>if ($var == "") {
      $var = 0;
  }
  </code></pre>
  
  <p>Is there a way in PHP i can automatically define if anything is nothing set the value of it to 0?
  I've tried</p>
  
  <pre><code>define('', '0');
  </code></pre>
  
  <p>But this hasn't worked</p>
  
  <p>Background:</p>
  
  <p>These "empty" values are being imported from lots of different types of APIs, if the users analytics do not exist, the values are set to "". When displaying this in a graph/chart/table it causes errors and breaking.</p>
  
  <p>Without having the set every variable as "0" from "" (How it's imported) - I need a quicker and more efficient method.</p>
  
  <p>Here's one of the API calls:</p>
  
  <pre><code>// January
      $janViews = file_get_contents('https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DMINE&amp;start-date='.$jan.'&amp;end-date='.$feb.'&amp;&amp;metrics=views%2Clikes%2CsubscribersGained%2Ccomments&amp;access_token='.$_SESSION['authcode']);
      $jsonJan = json_decode($janViews);
      $monthlyViewsJan = $jsonJan-&gt;rows[0][0];
      $monthlyLikesJan = $jsonJan-&gt;rows[0][1];
      $monthlySubsJan = $jsonJan-&gt;rows[0][2];
      $monthlyCommentsJan = $jsonJan-&gt;rows[0][3];
  </code></pre>
  
  <p>The above code is requested 12 times (Each month). Here's the verification for each month.</p>
  
  <pre><code>if ($monthlyViewsJan == "") {
      $monthlyViewsJan = 0;
  }
  if ($monthlySubsJan == "") {
      $monthlySubsJan = 0;
  }
  if ($monthlyCommentsJan == "") {
      $monthlyCommentsJan = 0;
  }
  if ($monthlyLikesJan == "") {
      $monthlyLikesJan = 0;
  }
  </code></pre>