addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1light-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

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

From: Darcy W. C.
Sent on: Tuesday, September 15, 2009 12:43 PM
i would agree with this, but unless you are using exceptions, (and avoiding all procedural code for your error handling - ie. functions), i think you are breaking OOP concepts anyway.



On Sep 15, 2009, at 12:36 PM, Mohamed wrote:

I think it breaks OOP concepts, and thus making your method a bad practise. simple true/false return is much better, because you can always check returned value and act accordingly. In short, your class is not reusable.

Thanks
Mohamed.

On Tue, Sep 15, 2009 at 12: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





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Mohamed ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Mohamed, 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


~/darcy w. christ
1000camels


Our Sponsors

  • PluralSight

    PluralSight subscriptions for developer training

  • O'Reilly

    Disc Code: PCBW is good for 40% off print and 50% off ebooks and videos

  • JetBrains PhpStorm

    Occasional free licenses to raffle off at meetups

  • DynaTrace

    Find yourself, promote yourself, stay true to yourself.

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