Re: [php-49] Is it bad practice to die 'inside' a class?

From: user 8.
Sent on: Tuesday, September 15, 2009 12:27 PM
I would submit that it is indeed a bad practice for a process to end without returning from within a class or structure like this. It would be different if there were a visitor method being used that actually did the redirect from the result of the class' method call, but to hard code a redirect like this and die within can cause for a massive amount of headache when trying to manage your code base down the road.

I'm not familiar enough with the garbage collection of PHP to answer for the raw memory consumption of following such a practice, but I can definitely answer from the practical coding side.

Hope this helps some.

Garth Henson
Guahan Web
Email: [address removed]
Web: http://www.guahanweb.com
Chat Google Talk: henson.garth Skype: guahan.web
Contact Me LinkedinFacebookTwitter





On Tue, Sep 15, 2009 at 3:23 PM, David Malouf <[address removed]> wrote:
Not sure if I can word this well, so please ask for clarification as needed...

Hypothetical example of the concept (that is, I'm not looking for a better way to do this particular task, just using it as a simplified example):

MainPage.php
?? <? php
?? include ('theClass.php');
?? $newUser = new theClass();
?? $newUser->checkIP;
?? echo "Welcome...";
?? ...
?? ?>

theClass.php
?? ...?????????????????? // setup-stuff
?? function chekIP() {
??????? if ($_SERVER['REMOTE_ADDR'] != '[masked]') {
??????????????? include ('aDifferentLoginPage.php');??????????? //? THIS LINE!!
? ? ? ? ? ? ? ? die();
??????? }
??? }


Roughly, if the user is not at[masked], then they are bounced out to a different page BY THE CLASS!!

1) Is this a bad idea or is it okay practice?
2) does this lead to memory-leak or other wasted RAM/processing issues?


David





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by David Malouf ([address removed]) from The Seattle PHP Meetup Group.
To learn more about David Malouf, visit his/her member profile
To unsubscribe or to update your mailing list settings, click here

Meetup Support: [address removed]
632 Broadway, New York, NY 10012 USA

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy