Static properties and variable classnames
Oh no!
<?php
class test {
static public $foo = 'test1';
static public $bar = 'test2';
function foo() {
print "method foo\n";
}
}
class test1 {
function __construct() {
print "test1 constructor\n";
}
}
class test2 {
function __construct() {
print "test2 constructor\n";
}
}
function test1() {
print "test1 function\n";
}
function test2() {
print "test2 function\n";
}
function foo() {
print "foo function\n";
return 'bar';
}
$foo = 'foo';
$a = test::$foo;
new $a();
new test::$foo();
$a();
print test::$foo();
?>test1 constructor
test1 constructor
test1 function
method foo

Comments
Wow
This does my head in, though it would help if the sample were a little cleaner. There seems to be much unused code in there. All the first parts seem to make a lot of sense, given the idea of variable variables. For the life of my, I can't figure out why that last one should result in the method call though. That's the only one that seems unintuitive.
Binding precedence
In the last line, $foo is being evaluated to the string 'foo' first, and then test::foo() is being called. That part makes sense.
The oddball here is that A::$b apparently means "Static variable b of class A" if there is no $b in scope at the time, but "Static variable the value of b in class A" if there is. That is, $ binds higher than :: does.
$ binding higher than :: explains all of the above code quite readily, even if it ends up looking bizarre. The alternative would make it impossible to call a variable class method or class property.
That said, I now have to wonder if there aren't security implications there...
This is perfectly legal,
This is perfectly legal, anything inside the braces is executed first, the return value then becomes the variable name. Echoing the same variable variable using the function that created it results in the same return and therefore the same variable name is used in the echo statement. Have fun ;).
Rolex Watches
This looks like normal
This looks like normal behavior to me. PHP is doing it correctly. You're underestimating the flexibility thats available to you in here.
Pretty good post. I just
Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts.I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have enjoyed reading. Nice blog. I will keep visiting. hypnosis therapy to stop smoking
I enjoyed reading your easy
I enjoyed reading your easy transformations. I see you offer priceless info. Stumbled into this blog by chance but I’m sure glad I clicked on that link. Forexhandel
divorce forms
Good stuff, thank you for the
Good stuff, thank you for the share..
workers compensation fraud prevention
tom ford sunglasses I used to
tom ford sunglasses
I used to be more than happy to seek out this internet-site.I wanted to thanks in your time for this glorious read!! I positively enjoying each little bit of it and I have you bookmarked to check out new stuff you weblog post
It is great to have the
It is great to have the opportunity to read a good quality article with useful information on topics that plenty are interested on
642-447 exam
PgMP exam
642-974 exam
JN0-101 exam
PW0-104 exam
JK0-018 exam
642-971 exam
642-427 exam
Generally I do not post on
Generally I do not post on blogs, but I would like to say that this post really forced me to do so, Excellent post!
divorce forms
It is so lucky to read your
It is so lucky to read your blog,it is full of useful message.I wish we both can do better in the future.It great honor if you can visit our website,and give us some suggestion.
70-297 dumps
640-460 dumps
BH0-006 dumps
70-272 dumps
70-431 dumps
642-825 dumps
70-448 dumps
642-446 dumps
Post new comment