develooper Front page | perl.php.sandwich.dev | Postings from August 2005

Re: Setting up a property on a Perl object causes segfault

Thread Previous
From:
David Wheeler
Date:
August 2, 2005 11:23
Subject:
Re: Setting up a property on a Perl object causes segfault
Message ID:
24C65F48-7546-4FA9-A517-2D3C4D333476@kineticode.com
On Aug 2, 2005, at 11:18 AM, David Wheeler wrote:

> So, you should *always* use accessor methods:
>
> sub test {
>     my $self = shift;
>     return $self->{test} unless @_;
>     $self->{test} = shift;
> }
>
> Then, your PHP code should:
>
>   echo $obj->test();
>   echo $obj->test(2);

That said, I would expect it to work if you treated the object as a  
hash in PHP:

   echo $obj['test'];
   echo $obj['test'] = 2;

Hrm, but it doesn't:

Fatal error: Cannot use object of type PerlSV as array in  
PHP::Interpreter::eval on line 28
A PHP error occured

Any ideas, George? (I'll fix the misspelling :-)).

Best,

David


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About