Re: RE:Class::? - accessing data, no success...
| From: | Ulf Wendel | Date: | Tue, 04 Jul 2000 11:08:03 +0000 |
| Subject: | Re: RE:Class::? - accessing data, no success... | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-23437@lists.php.net to get a copy of this message | ||
waldschrott wrote:
> The most important thing is retrieving the data, if one could change the
> initial class declaration with $class::var=$x; - nice, but I think
> Zeev&Andi won´t like that ;) - and if you decide implementing this
You're right we need "read only" access.
Please do not implement $class::var = $x. This would cause
confusion and it would not make any sense. Use objects to do such
things.
> post-declaration-modification, you´ll have to add this functionality for
> methods too (perhaps nice too).
> As said, retrieving the data is the hard point...
Stanislav, you asked which vars we want to access using the "::"
operator. I would love to be able to access the class properties
( get_class_vars() ) but not the object properities (
get_object_vars() ).
+++ That's what I want ++++
<?php
class foo {
var $bar = "this one is good";
function foo() {
print "silly example";
}
}
print foo::bar; // static (read-only!) access of a property
foo::foo(); // static access of a method
?>
+++ Not very beautiful, but legal +++
I don't not like this snippet that uses $this, but I can life
with it:
<?php
class foo {
function foo() {
$this->bar = 8; // dirty, because there's no foo
print $this->bar; // object but a default class
}
}
foo::foo();
?>
+++ Invalid +++
<?php
class foo {
var $foobar;
function foo() {
$this->bar = 8;
}
}
foo::foo();
foo::bar; // Parse error: No such class variable
foo::foobar; // Warning: Uninitialized class variable, NULL
returned
?>
Ulf
--
Ulf Wendel
NetUSE AG
Siemenswall, D-24107 Kiel, Germany
Fon: +49 431 386435 00 -- Fax: +49 431 386435 99