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: David M.
Sent on: Tuesday, September 15, 2009 5:39 PM
What I wrote initially is that the checkIP() function is not actually what I'm asking about.�� It's just an over-simplified example of breaking out in the middle of a class.�� The class issue is at-hand, not the IP check.

Sorry for the mis-communication,
David




On Tue, Sep 15, 2009 at 4:43 PM, Tim Piele <[address removed]> wrote:
I am certainly no OOP expert, but is this so wrong for this purpose? This all seems to be overly complicating things. I mean, are you literally checking for one specific IP address, or maybe an array of IP address, like in a blocked IP address list for a forum? If it's the later just explode an array and run a for each loop over it.


if ($_SERVER['REMOTE_ADDR'] != '[masked]') {
������������������������������ header("aDifferentLoginPage.php");
������������������������������ exit;
�������������� }

else {
��// rock out with you code block out
}





On Tue, Sep 15, 2009 at 12:57 PM, Tim Piele <[address removed]> wrote:
Why not use a header redirect?


function chekIP() {
�������������� if ($_SERVER['REMOTE_ADDR'] != '[masked]') {
������������������������������ header("aDifferentLoginPage.php");
������������������������������ exit;
�������������� }
}




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 Tim Piele ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Tim Piele, 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

  • 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