Re: Any way to make something happen when variable in classchanges?
| From: | Brad Bonkoski | Date: | Thu, 17 Oct 2002 23:55:59 +0000 |
| Subject: | Re: Any way to make something happen when variable in classchanges? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120442@lists.php.net to get a copy of this message | ||
Well, I've never done this in PHP, but in other OO programming languages you can overload the
assignment operator, so when you assign a new value to a
variable it would actually call a class-defined function that could make the new assignment, but
also echo out any code you want it to do. Have you
looked at this possibility?
-Brad
Leif K-Brooks wrote:
> Yes, but it needs to run when it's changed. For example, when I change
> the variable $var, it would echo "Changed!" (without putting the echo
> where it's changed).
>
> Catherine Pinatiello wrote:
>
> > I'm thinkin he means is there a way to track variable changes.
> >
> > Yes, copy the variable:
> >
> > $var = 8;
> > $oldvar = $var;
> >
> > (code that changes $var)
> >
> > if ($var != $oldvar) {
> > (do stuff here that you want to happen if $var is changed)
> > }
> >
> > Rick Emery wrote:
> >
> >> that is the most vague question I've ever seeen posted here...not
> >> good thing
> >>
> >> ----- Original Message ----- From: "Leif K-Brooks"
> >> <eurleif@buyer-brokerage.com>
> >> To: <php-general@lists.php.net>
> >> Sent: Thursday, October 17, 2002 6:19 PM
> >> Subject: [PHP] Any way to make something happen when variable in
> >> class changes?
> >>
> >>
> >> Is there a way to make something happen when a variable is changed in
> >> a function? I need to be able to do something like this for my class
> >> which manipulates a record in the database.
> >>
> >
> >
> >
>
> --
> The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt
> it will be prosecuted to the full extent of the law.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php