FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » question about class getters
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: question about class getters [message #180870 is a reply to message #180842] Sat, 23 March 2013 07:14 Go to previous messageGo to previous message
Curtis Dyer is currently offline  Curtis Dyer
Messages: 34
Registered: January 2011
Karma:
Member
Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:

> On 3/21/2013 5:31 AM, Curtis Dyer wrote:
>> Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:
>>
>>> On 3/15/2013 1:53 PM, David Heller wrote:
>>>> On Mar 15, 1:11 pm, Jerry Stuckle <jstuck...@attglobal.net>
>>>> wrote:
>>>> > On 3/15/2013 11:42 AM, David Heller wrote:

<snip>

>>>> public function __construct() { // Constructor
>>>> $this->my_array = array('Mon', 'Tues', 'Wed',
>>>> 'Thurs', 'Friday',
>>>> 'Sat', 'Sun');
>>
>> Just out of curiosity, why is `Friday' the only day of the week
>> that's not abbreviated in your list?
>
> It's not my list.

Right, but this portion of my response was to the OP. If I botched
my quoting, my apologies.

<snip>

>> Yes, the `__get()' magic method expects a string, and moreover,
>> if the OP intends to use the class similarly to the code they
>> posted initially, it would be a syntax error:
>>
>> echo $obj->2; /* parse error */
>>
>> Using a custom getter method as you posted above, IMO, seems
>> easiest.
>
> echo $obj->'2'; should work (although I haven't tried it).

That's still a syntax error; I tested in 5.4.12. However, I haven't
bothered to check if it works in prior versions.

--
Curtis Dyer
<?$x='<?$x=%c%s%c;printf($x,39,$x,39);?>';printf($x,39,$x,39);?>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Will this set or get a SESSION variable?
Next Topic: Fatal error!
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 20:35:19 GMT 2024

Total time taken to generate the page: 0.03960 seconds