Brad Brad - 1 year ago 114
PHP Question

Disable errors when getting postal code using

I'm retrieving the postal code by using -

<?php $pstcde = file_get_contents(''.$_SERVER['REMOTE_ADDR'] . '/postal/'); ?>

It works great but if the postal code is not found, it says, "None". I can't find a way to disable the message.

Answer Source

You can empty the variable if the respond is None. With a simple check.

  $pstcde = file_get_contents(''.$_SERVER['REMOTE_ADDR'] . '/postal/'); 
  if($pstcde === "None") 
      $pstcde = ""; //Empty string. Or you can use unset($pstcde); if you want to unset the variable.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download