Jump to content

Error Suppression


mrbean

Recommended Posts

What exactly are you trying to accomplish?

 

If the include statement is failing, the file isn't being included. If it's not being included, it's not being parsed, tokenized, and interpreted. if it's not being parsed, tokenized, and interpreted, there's no way to find and report the errors in it.

Link to comment
Share on other sites

Why are you using error suppression if not to hide errors? In fact why are you suppressing errors at all? Fix them instead.

What exactly are you trying to accomplish?

 

If the include statement is failing, the file isn't being included. If it's not being included, it's not being parsed, tokenized, and interpreted. if it's not being parsed, tokenized, and interpreted, there's no way to find and report the errors in it.

 

I will explain it to you guys.

 

I have 2 files.

 

One is the file with the functions

The other file will include the functions file.

For example:

The function file contains:

<?php
class sadasd
{
function
function
}
class lsadasd
{
function
function
function with an error
}
?>

File that includes the function

<?php
$functions_file = @include(dirname(__FILE__)."/functions.php");
if(!($functions_file))
{
   $try_default_functions_file = @include(dirname(__FILE__)."/functions.php");
   if(!($try_default_functions_file))
   {
       echo "<h1>Error</h1><br>";
       echo "kan de functies bestand niet vinden.<br>";
       echo "Could not find the functions file.<br>";
       exit;
   }
   echo "error with including file.";
}
$test = new function();
$test->something();
//this should return test
echo "test";
?>

 

Because the function.php an error contains nothing is shown.

I only want to suppress the function "include" if it fails trigger an custom error to prevent hackers to see further info.

But not if there is an internal error in function.php

Link to comment
Share on other sites

<?php
@require_once('test');
echo 'hello world';
?>

require_once will only include the file once, and it will exit() the script if it is not able to include the file, at least that's my experience using it.

So in this case, it would return "hello world" only if it finds and is able to include the file named "test".

I also suppress the error, because you may not want to show that to the user.

 

If you want to show a custom error message to the user:

<?php
$included = @include_once('test');
if(!$included){ echo 'was not able to include the file'; exit(); }
?>

Edited by MMDE
Link to comment
Share on other sites

Because the function.php an error contains nothing is shown.

I only want to suppress the function "include" if it fails trigger an custom error to prevent hackers to see further info.

But not if there is an internal error in function.php

 

This doesn't make any sense as it's currently written.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.