Jimmy's Blog

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:

  1. Java – Adding new Classpath at Runtime

:,

2 Comments for this entry

  • Edd Slipszenko

    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

  • wzlcm

    Hi, nice post. I have been thinking about this issue,so thanks for writing. I will certainly be subscribing to your blog.

Leave a Reply

Spam Protection by WP-SpamFree

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...