Mike
Mike

Reputation: 1738

Disable warnings and notices for part of a page php

We are trying to add the PHP Library PHPDocx for dynamically making Microsoft word docs through our php application. However, their code throughs several warnings and notices that are blowing up our error log. We have our error reporting set to E_STRICT for the site, and want to change the error reporting and logging to E_ERROR just for these files. Unfortunately, our custom templating system (which sets the error reporting), is loaded prior to any requires or references to the PHPDocx library.

I have tried using error_reporting(E_ERROR) and ini_set('display_errors', 0), but I am still getting the warnings and notices written into our error log. I don't know if its because all of our setup code is run first, but what I would like to do do is only write fatal errors from the PHPDocx files, but keep E_STRICT on the rest of the site.

Thanks for any help.

Upvotes: 1

Views: 2381

Answers (2)

Manny
Manny

Reputation: 562

error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
ini_set('display_errors', 1);

Upvotes: 0

Dave
Dave

Reputation: 1001

if they are a small number of occurances, you could specifically suppress them with the @ symbol before whatever function. for example;

echo @$myunsetvariable;

Upvotes: 3

Related Questions