/    Sign up×
Community /Pin to ProfileBookmark

Suppressing PHP warnings

Hi,

I’d like to know why some warnings can’t be suppressed using error_reporting()or ini_set() For example: ‘Warning: Call-time pass-by-reference has been deprecated’

I know how to get ride of that warning, using the .htaccess file, php.ini or fixing the code, but my question is: why error_reporting() or ini_set(“display_errors”, “FALSE”) won’t work with this particular warning?

Thanks.

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@JonaFeb 07.2005 — [font=trebuchet ms]Use the @-symbol in front of a function to supress the error:[/font]

[code=php]
@call();
[/code]


[font=trebuchet ms]Also, it might not make a difference in PHP, but you shouldn't put quotes around FALSE, just in case.[/font]
Copy linkTweet thisAlerts:
@StrikeauthorFeb 07.2005 — I've tried using '@' in front of the function call but it has no effect on this warning. My function call is this:

$fp = @fsockopen("www.example.com", "80", &$errno, &$errstr, 10);

Let's say that there's no service on port 80, I can suppress the warning that rises fsockopen() about not being able to connect to the remote host. But the warning about passing an argument by reference at function-call time is still there, the complete output is this:

Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of fsockopen(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer.

The only reason I can think of is that since 'allow_call_time_pass_reference' can't be changed in user scripts, then a warning related to this option can't be suppressed from the script. Is this correct?
Copy linkTweet thisAlerts:
@ShrineDesignsFeb 07.2005 — this turns off errors[code=php]<?php
error_reporting(0);
?>[/code]
Copy linkTweet thisAlerts:
@StrikeauthorFeb 07.2005 — Nop, error_reporting(0) doesn't work in this case. In fact I know how to prevent this warning to display, you just have to get ride of the reference operator in the function's arguments. What I want to know [and confuses me] is why the methods that I know for turning off warnings, don't work in this case. Anyway, thanks for your replies guys.
Copy linkTweet thisAlerts:
@ShrineDesignsFeb 07.2005 — oh duh, i did even look at that, for that function, it automatically references those variables $errno and $errstr
Copy linkTweet thisAlerts:
@DaiWelshFeb 07.2005 — It is the difference betwen compile-time and run-time errors - using error_reporting(0) suppresses errors [B]after[/B] that line of code has been run, but even if it is the first line in your script it will not be run until PHP has compiled the script. Therefore compile-time errors are unaffected. ini settings take effect immediately so this does not apply to them.

HTH,

Dai
Copy linkTweet thisAlerts:
@StrikeauthorFeb 07.2005 — That makes sense, thanks a lot.
×

Success!

Help @Strike spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...