PHP5/ZE2: variables definition, constant variables
| From: | Victor Toni | Date: | Fri, 03 Jan 2003 03:53:12 +0000 |
| Subject: | PHP5/ZE2: variables definition, constant variables | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-93060@lists.php.net to get a copy of this message | ||
Hello,
I am using mainly C/C++, but have some experience with Java, VB,
JavaScript etc.
I started to use PHP4 about 3 months ago, and I am very impressed how
fast it can be learned.
My understanding of the languages cababilities is definitely less then
complete, but I am already missing some features.
Namespaces, static and privat class variables are scheduled for PHP5.
What I do not like about PHP variables, is that they do not have to be
defined before use.
Also there is some inconsistence at this. Personly, I would like a
behaviour similar to visual basic.
Maybe with some kind of option variable (maybe only responsible for
actual context (class, namespace, file)).
- Victor
-----------------------------------------------------------------------------------------------
Case 1 (strict):
class a {
$OPTION['strict'] = true; // only for this class
var $ID; // define ID
var static $count = 0; // define ref counter
function a() {
$this->ID = self::$count++; // this would result in an error if ID
is not defined
$ID = $this->ID; // works in PHP3/4 , should result in an error in
PHP5 with strict checking
echo $this->ID;
}
-----------------------------------------------------------------------------------------------
Case 2 (loose/normal):
class b {
static $count = 0; // define ref counter
function b() {
$this->ID = self::$count++; // works
$ID = $this->ID; // works too
echo $this->ID;
}
-----------------------------------------------------------------------------------------------
one more think I do not like is:
class foo {
const hey = 'hello';
}
print foo::hey;
-----------------------------------------------------------------------------------------------
should be:
class foo {
const $hey = 'hello';
}
print foo::$hey;