Brad Brad - 2 months ago 14x
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.


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.