-Hellow DANIWEB?...
-I've been wondering if there is a way I can Use My Own Warning Message instead of that provided by Php during file include Failure...
-NOTE:I dont intend to Mean Error Messages that We can write to a User when something goes wrong,like failure of inserting data inputs to the data base or like so.
-What I mean is the warning messages I get when I use the function:include("sample_files/sample.php"); and when the File sample.php doesn't exist Php gives Me a warning:
"Warning: this_used_object ::include() [function.include]: Failed opening 'sample_files/sample.php' for inclusion (include_path='.;C:\php5\pear') in My Root_Folder on line 240"
-And My be I use something like "Sorry the Page is Under Maintanance Please Visit some other time"
-Any Sugestions ,please?...

Create a custom error handler
It is possible to override PHP's default mechanism for handling errors. This option gives the programmer full control over what actions to take when an error is raised. Note that since this method completely replaces PHP's native functionality, it is important to pay special care when writing a custom error handler.

// Destinations
define("ADMIN_EMAIL", "nobody@stanford.edu");
define("LOG_FILE", "/my/home/errors.log");

// Destination types
define("DEST_EMAIL", "1");
define("DEST_LOGFILE", "3");

/**
  * my_error_handler($errno, $errstr, $errfile, $errline)

  * custom error handler
  *
  * Parameters:
  *  $errno:   Error level
  *  $errstr:  Error message
  *  $errfile: File in which the error was raised
  *  $errline: Line at which the error occurred
  */

function my_error_handler($errno, $errstr, $errfile, $errline)
{  
  switch ($errno) {
    case E_USER_ERROR:
      // Send an e-mail to the administrator
      error_log("Error: $errstr \n Fatal error on line $errline in file $errfile \n", DEST_EMAIL, ADMIN_EMAIL);

      // Write the error to our log file
      error_log("Error: $errstr \n Fatal error on line $errline in file $errfile \n", DEST_LOGFILE, LOG_FILE);
      break;

    case E_USER_WARNING:
      // Write the error to our log file
      error_log("Warning: $errstr \n in $errfile on line $errline \n", DEST_LOGFILE, LOG_FILE);
      break;

    case E_USER_NOTICE:
      // Write the error to our log file
      error_log("Notice: $errstr \n in $errfile on line $errline \n", DEST_LOGFILE, LOG_FILE);
      break;

    default:
      // Write the error to our log file
      error_log("Unknown error [#$errno]: $errstr \n in $errfile on line $errline \n", DEST_LOGFILE, LOG_FILE);
      break;
  }

  // Don't execute PHP's internal error handler
  return TRUE;
}


// Use set_error_handler() to tell PHP to use our method
$old_error_handler = set_error_handler("my_error_handler");

--Thank You imti321,I hope I decided to use the "file_exits()" to heck if the file exists then I load it by suing the "include()" if it doesn't exist in My given directory path I just load the default page.
--Thaks anyway,and I'll still try to catch up with Your code coz I get confused with some sort of things there.But I'll be intouch I just need to sort Myself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.