Jump to content

[SOLVED] throw new Exception... trouble


unkwntech

Recommended Posts

I have a block of code that looks like this:

function sendResponseCode($code)
{
	error_reporting(0);
	switch ($code)
	 {
                ...SNIP...
	 	default:
	 		throw new Exception('Response Code Not Implemented', '1');  //<-- LINE 11
	 		break;
	 }
	die();
}
...SNIP...
if(!DEFINED(constName))
{
	try
	 {
	sendResponseCode(404);
	 }
	catch(Exception $e)
	 {
		echo $e->getMessage() . ' on line: ' . $e->getLine() . ' of file ' . $e->getFile();
	 }
}

when I run it I am getting the following:

Parse error: parse error, unexpected T_NEW in ...SNIP... on line 11
Link to comment
Share on other sites

function sendResponseCode($code)
{
	error_reporting(0);
	switch ($code)
	 {
                ...SNIP...
	 	case 404:
	 		header('HTTP/1.1 404 Not Found\r\n');
	 		break;
	 	default:
	 		throw new Exception('Response Code Not Implemented', '1');
	 		break;
	 }
	die();
}
...SNIP...
if(!DEFINED(constName))
{
	try
	 {
	sendResponseCode(404);
	 }
	catch(Exception $e)
	 {
		echo $e->getMessage() . ' on line: ' . $e->getLine() . ' of file ' . $e->getFile();
	 }
}

Link to comment
Share on other sites

I'm gonna' beat my head against the desk for a while now.... the server I was testing on hadn't been updated for whatever reason to PHP5 so it was still running 4.4.0.

So I'll change the question is there a way to accomplish this in 4?

 

 

Note To Self: Check the versions don't rely on what 'they' tell you.    :P

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.