Pain Posted November 20, 2012 Share Posted November 20, 2012 Hello again. I am trying to extend a class, but it gives me an error: Fatal error: Class 'Redirection' not found in /home/searchqu/public_html/game/class.session_destroy.php on line 3 Im trying to extend the logout class: <?php session_start(); class SessionDestroy extends Redirection{ public function destroy_session() { session_destroy(); Redirection::redirect("login"); } } ?> this is my redirection class: <?php class Redirection { function redirect($parameter) { header("Location: $parameter"); } } ?> and this is my actual logout page: <?php ob_start(); require('class.session_destroy.php'); require('class.redirect.php'); $logout = new SessionDestroy; $redirect = new Redirection; $logout->destroy_session(); ob_end_flush(); ?> What could be the problem here? Thanks:] Quote Link to comment Share on other sites More sharing options...
kicken Posted November 20, 2012 Share Posted November 20, 2012 swap the order of your require statements. You have to define the redirection class before you can extend it. Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted November 20, 2012 Share Posted November 20, 2012 erm...I fail to see how either of those classes merit actualy being classes in this scenario. You also have no scope on function redirect() You do have the Redirect class declaired before the SessionDestroy one right? if it deffinately is then have you tried calling $this->redirect() or $parent->redirect() ? Quote Link to comment Share on other sites More sharing options...
Pain Posted November 20, 2012 Author Share Posted November 20, 2012 kicken cheers, swapping those two lines has fixed the error. Muddy_Funster so you think i should simply write them down in a procedural style? Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted November 20, 2012 Share Posted November 20, 2012 The way you are calling the the classes through includes, and the fact that each class basicly performs a single line of code, yeah, procedural would make more sense to me. It's just my point of view, there are others about that would tell you to even allow the word procedural to enter your mind unbidden is punnishable by 3 lashes and 4 hail Marys. Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted November 20, 2012 Share Posted November 20, 2012 Classes are meant to group related data and the functions that operate on that data together. Why are you using classes to begin with here? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.