In response to jason:
I continued here.
OOP session strategy brainfart
Moderator: General Moderators
I wouldn't presume to tell you what your coding style should beHeavy wrote:In response to McGruff:
What is "Camel back var names"?
I didn't think get_class_vars would work in the constructor since the class hasn't been properly initialised yet. Still not easy about that..Ummm... If you do a print_r($arrVarNames), you'll see that it [.. the populate fn..] works.
This works fine:
Code: Select all
<?php
class Bar
{
var $var1 = null;
var $var2 = null;
var $var3 = null;
//..etc
?>I maybe didn't pick up on that behaviour. Sure: pass a string in and use that.Also. Looking at your reply. What happens if you create two different objects of the one of your classes? You break the property references to the session! I passed the name of the object to the constructor to distinguish between objects, not classes.
Yes. The code I posted passes vars to session by ref same as your own. I was thinking out loud if it might not be a good thing to do for the above reasons.Indeed. I don't get what you are talking about. You are using the same $_SESSION global as I am, and you are not protecting it from beeing accessed any more than I do.
I guess you mean the typo. Guilty as charged (see what I mean about coding styles?). There wasn't any need to test a sample script - it's just there to show what I think is a slightly clearer way to do what you're doing. I don't like the populate fn: I have to stop and think about what it's doing (so will you in a few months time) but the other way I can see immediately what's going on - and also see at a glance what properties are set in the class.I question that your code has been tested, because:
- $this->fooVar = 10; cannot point to var $foovar;
Pretty minor differences, all in all.
Last edited by McGruff on Wed Aug 10, 2005 6:04 pm, edited 1 time in total.