$this->error->trigger('noRoute','URL Has No Matching Route',array('URL'=>$url),'404');
Isn't that code meant to be the following:
$this->$error->trigger('noRoute','URL Has No Matching Route',array('URL'=>$url),'404');
The code above will only work if $error is a method of $this and trigger() is a method of $error. Also you forgot a dollar sign for the middle variable.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
Isn't that code meant to be the following:
$this->$error->trigger('noRoute','URL Has No Matching Route',array('URL'=>$url),'404');
The code above will only work if $error is a method of $this and trigger() is a method of $error. Also you forgot a dollar sign for the middle variable.
Why does he need a dollar sign? I don't think he wants it to be a dynamic call.
Also, can you post your code cloudedvision? That way we can help debug it better.
Lately I have been building my personal php framework and have a error logger like yours. It shouldn't be hard to find the problem.
kkeith29
Nearly a Posting Virtuoso
1,357 posts since Jun 2007
Reputation Points: 235
Solved Threads: 194
Why does he need a dollar sign? I don't think he wants it to be a dynamic call.
Also, can you post your code cloudedvision? That way we can help debug it better.
Lately I have been building my personal php framework and have a error logger like yours. It shouldn't be hard to find the problem.
From what I have learnt in oop php-gtk, variables are the containers and in that code it appears to the left is the parrent - in the middle is the container and to the right is the method. If however you are trying to call two methods at the same time then that will never work and needs to be set on two lines with another container. So the previous post of mine was assuming $error was a container. If that is not the case and 'error' is a method then the following is what you may need to do:
$container=$this->error;
$container->trigger('noRoute','URL Has No Matching Route',array('URL'=>$url),'404');
//or
$container=$this->error();
$container->trigger('noRoute','URL Has No Matching Route',array('URL'=>$url),'404');
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
Where did it say he's using php-gtk?
He is just referencing another class through the error variable.
You also can call two methods at once with oop. All you have to do is return $this in the function.
kkeith29
Nearly a Posting Virtuoso
1,357 posts since Jun 2007
Reputation Points: 235
Solved Threads: 194
Where did it say he's using php-gtk?
I didn't say he is using php-gtk but I said from my experience of php-gtk which is just like php.He is just referencing another class through the error variable.
If error is a variable then the error variable will need the $ sign before it. Note that dynamic variables have $$ before the name of the variable.You also can call two methods at once with oop. All you have to do is return $this in the function.
Although that is usually true there are some cases where that is not possible. I forget the reason but it only happens with certain objects.
-------
Also with the additional info kkeith29 has posted, perhaps the following code would be more relevant to test the problem.
$tester=$this->error;
$tester->trigger('noRoute','URL Has No Matching Route',array('URL'=>$url),'404');
If line one of the above code reports the error then you know that theerror variable needs to be defined properly. If however it is the second line of the above code that reports the error then it is the trigger method that needs adjusting.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
I didn't say he is using php-gtk but I said from my experience of php-gtk which is just like php.
If error is a variable then the error variable will need the $ sign before it. Note that dynamic variables have $$ before the name of the variable.
Although that is usually true there are some cases where that is not possible. I forget the reason but it only happens with certain objects.
-------
Also with the additional info kkeith29 has posted, perhaps the following code would be more relevant to test the problem.
$tester=$this->error;
$tester->trigger('noRoute','URL Has No Matching Route',array('URL'=>$url),'404');
If line one of the above code reports the error then you know that theerror variable needs to be defined properly. If however it is the second line of the above code that reports the error then it is the trigger method that needs adjusting.
Dynamic variables work differently in oop. Putting a $ in front of the variable doesn't work.
ex.
$this->$error->trigger('blah');
is run as
$this->->trigger('blah');
if $error is not defined outside the class.
You do not need a $ to reference variables inside a class. I think I am misunderstanding your take on this.
kkeith29
Nearly a Posting Virtuoso
1,357 posts since Jun 2007
Reputation Points: 235
Solved Threads: 194
If it's just dying with no message you might want to check to see if you have your error_reporting ini value set to something other than E_ALL (development only, don't turn this on live). Also, consider using braces around your conditions even if it's only one statement. It disambiguates the statements and is less confusing. I can't tell you how many times I've forgot the braces then added another statement and wondered why it didn't execute.
Also, your classes are dynamically instantiating members you should probably define them before-hand to make things easier, ie.,
class Log
{
/**
* File handle for the log
* @var Resource
*/
private $handler = NULL;
ShawnCplus
Code Monkey
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
Its definitely E_ALL, my framework automatically sets it to that in development mode. fwrite returns an integer, not false, so there is no error there. (But for some reason it doesn't work)
I've heard the tip about using brackets always, but I've never have bothered because I don't forget to add brackets when I add another statement. (Which is weird, I always end up forgetting to close up multiple parenthesis, add periods to connect strings and variables, etc.)
Well its more of a style choice really but if you're building a framework it usually means you're going to release it to the public and I'd say a majority of programmers whether they use Allman/BSD or K&R/OTBS style they do prefer to have closing braces.
In your trigger function always exit after a header() call so in that case you will need the braces because of having 2 statements. You don't need the other exit so just move it right after the header() call inside that condition
ShawnCplus
Code Monkey
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
$this->load('classes/errorHandler');$this->error = new errorHandler($mode, &$this->errorLog);
That makes more sense because I was thinking along the lines of $error = new errorHandler($mode, &$this->errorLog); . Although I'm not a big fan of pure oop pages I would suggest to check if trigger is a member/method of the error object.
Although I would have to say I haven't seen somebody define an object using that style before but there isn't much more that I can recommend.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259