Learn some PHP and see variable function names (omg)
by jimmy on Nov.02, 2007, under English, PHP, Programming
Because my current team consist Java & PHP programmers I start to learn some PHP basic, point of view, and it’s programmer paradigm
I learn that this code is actually works :-p
<?php
$someVariable = “anyName”;
$name = “Jimmy”;$someVariable($name);
function anyName($name) {
echo “$name, Hello World”;
}?>
The statement “$someVariable($name);“ really call method anyName.
Although I fascinated by how dynamic it is (I remember encounter it at VBA), but personally I against it.
I don’t think it is a good practice, and it’ll be hard to be understand by other programmer.
Or is it because my Java programming paradigm….
Related posts:
November 18th, 2008 on 4:41 am
Had I not just found It very necessary to use this page and http://php.mirrors.ilisys.com.au/manual/en/functions.variable-functions.php
I would probably agree that this is confusing. But In building a PHP framework at the moment I have just found the complete necessity for the use of this code. So I now think that it’s great that we have the option to do such things. Even though It may be hard to explain and maintain, when you need something like this, It really can be a saviour!
Good to hear someone else’s opinion on this though! Thanks,
Edd Slipszenko
May 4th, 2009 on 6:33 pm
Hi, nice post. I have been thinking about this issue,so thanks for writing. I will certainly be subscribing to your blog.