hi,
it's a limitation, and not allowed in PHP. There was a whole line of posts about it in internals.


- Tul

Jake Press wrote:
Hello All,


I am having an interesting syntax problem. :(
I have been battling this little bugger for the last week and a half, I have exhausted google and numerous php channels in that time.


I am starting to beleive it could be a syntax that is sofar un-documented or an unclear syntax limitation (read as: bug?).



PHP Version:
------------
PHP Version 5.1.0-dev
- And has been tested on numerous other builds/versions


Problem: --------

I am trying to access a static member of a class dynamically.
ie.

   $foo = 'className';
   echo $foo::$staticMember;


Example Code: -------------

<?php
// Define a class with a nice juicy static variable
class bob {
public static $type = 'safd';
}
// Lets chuck the name of the class into a variable...
$foo = 'bob';
// Just to show it all works lets do it manualllllly
echo bob::$type;
// This is the line with the well-wicked parse error on the double colon
echo $foo::$type;
?>


Note that the last line in this example code generated a syntax error:
Parse error: parse error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting ',' or ';' in /mnt/data0/www/twd/test.php on line 15
I'm aware that the current syntax is definately wrong, but for simplicity i think its a good example.


I think i have ruled out its an internal scoping issue within php by successfully using eval() to them same effect.
ie.
eval('echo '. $foo .'::$type;');









Thanks in advance for any Thoughts, Answers and Comments Regards
Jake Press

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to