<?php
public function errorCheck()
{
$displayErrorsTo = array('127.0.0.1', '12.34.56.78', '000.000.000.000');
if (in_array($_SERVER['REMOTE_ADDR'], $displayErrorsTo))
{
$error = "System error: " . $text . "<br />";
$error .= "Text: " . $text;
}
else
{
$error = "Out site has encountered an error we are trying to fix it as much as we can.";
}
return $error;
}
That wouldn't work in that context because the variable $text would always be null, as it isn't being passed into the function, or isn't being referenced from a global perspective. That function also doesn't check for an error, it just simply provides an error message based on the users IP, regardless if there is actually an error or not.PHP:<?php public function errorCheck() { $displayErrorsTo = array('127.0.0.1', '12.34.56.78', '000.000.000.000'); if (in_array($_SERVER['REMOTE_ADDR'], $displayErrorsTo)) { $error = "System error: " . $text . "<br />"; $error .= "Text: " . $text; } else { $error = "Out site has encountered an error we are trying to fix it as much as we can."; } return $error; }
Just call $class->errorCheck() to echo the message.
I agree with you on the text part, missed that out in the hurry. However, it would do the same thing as normal PHP in a page as your script.That wouldn't work in that context because the variable $text would always be null, as it isn't being passed into the function, or isn't being referenced from a global perspective. That function also doesn't check for an error, it just simply provides an error message based on the users IP, regardless if there is actually an error or not.
public function errorCheck($text = null)
{
$displayErrorsTo = array('127.0.0.1', '12.34.56.78', '000.000.000.000');
if (in_array($_SERVER['REMOTE_ADDR'], $displayErrorsTo) && !is_null($text))
{
$error = "System error: " . $text . "<br />";
$error .= "Text: " . $text;
}
else
{
$error = "Out site has encountered an error we are trying to fix it as much as we can.";
}
return $error;
}