Question About PHP Error Reporting

Discussion of non-phpBB related topics with other phpBB.com users.
Forum rules
General Discussion is a bonus forum for discussion of non-phpBB related topics with other phpBB.com users. All site rules apply.
Carla_Rogers
Registered User
Posts: 0
Joined: Tue Feb 20, 2024 5:42 pm

Question About PHP Error Reporting

Post by Carla_Rogers »

This is not about phpBB. This is a simple php question that should not be confusing, bu I am confused.

I am trying to block some error messages from the screen, but having no luck.
I have a file in a php app I developed over the last 10 years. Now, the app is throwing error messages at me and I cannot figure out how to turn those message off. I think I can solve the error, but I have not been able to figure how prevent php from reporting this error in the display screen.

The file I am talking about is function file. containing a lot of long functions. Here is a section of that file that throws an error:

Code: Select all

if(function_exists('bounce')):else:
       function bounce($bounce_type){
		$back=debug_backtrace (DEBUG_BACKTRACE_PROVIDE_OBJECT,1);
		puttrace(__LINE__,__FILE__, 'called by',basename($back[0]['file'].' line: '.$back[0]['line']));
		puttrace(__LINE__,__FILE__, 'BOUNCING FOR NON '.$bounce_type.' CREDENTIALS', 'BOUNCING FOR NON '.$bounce_type.' CREDENTIALS');
		switch($bounce_type):
			case('logged in'):
				$bounce_msg='Thank you for your interest in exploring our website.  Special authorization is required for access to this area.';
				break;

			case('admin'):
				$bounce_msg='Thank you for your interest in exploring our website.  Administrators are authorized to access this area.';
				break;

			case('affiliate'):
				$bounce_msg='Thank you for your interest in exploring our website.  Affiliates are authorized to access this area.';
				break;

			default:
				$bounce_msg='Please try again later.  Thank you.';
				break;
		endswitch;
			?>
			<html>
			<head>
				<body>
					<script><?
						$destination=climbDir($GLOBALS['baseURL'],1);?>
						alert('<?=$bounce_msg?>  Nearest destination to the one requested: <?= basename($destination) ?>.  Checking for authorization to that area...');
						window.location = '<?= $destination?>'
					</script>
				</body>
			</head>
			</html><?php
			die;

	}
endif;
There error throws is this:

Parse error: syntax error, unexpected '}' in /var/www/www.legacy-systems.biz/htdocs/longview2 ... ctions.php on line 1027


To try blocking the error message from appearing, I tired inserting error_reporting funciton calls, but that made no difference?

ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(0);

Those code blocks were placed inside the php function having the problem.


Any ideas or suggestions for putting an end to these problems?
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3789
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay

Re: Question About PHP Error Reporting

Post by Kailey »

Hello,

Welcome to phpBB. However, as you mentioned, this site is not for general PHP support. I would suggest looking through the dedicated PHP support page. You may also be able to pose your question at Stack Overlfow's PHP page or another online resource

I will leave this topic open should members of this community wish to assist you. ;)
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules
If you have any questions about the rules/customs of this website, feel free to send me a PM.

My little corner of the world | Administrator @ phpBB Modders

Return to “General Discussion”