Ok, I'm in need of a sanity check here.
step one:
$input = "foo";
$scanning_class = "clamav";
$result = $scanning_class::scanBuffer($input);
now this fails with a "Parse error: parse error, unexpected
T_PAAMAYIM_NEKUDOTAYIM"
So ok, you can't put variables at the front on a class call like that.
Minor bug I'm thinking at this point, but I wonder if I can work round
it. So, onto step two:
$input = "foo";
$scanning_class = "clamav";
$func = $scanning_class."::scanBuffer";
$result = $func($input);
Which fails with a "Fatal error: Call to undefined function
clamav::scanBuffer()"
Just doing:
$result = clamav::scanBuffer($input);
of course works absolutly fine.
Somebody just tell me that this isn't exactly expected behaviour and
it's a minor bug
this is all on 5.0.3 btw.
Cheers.
--
Gareth Ardron
Hi,
This looks a lot more like a limitation of the Zend engine to me. The
second observation you made is correct, at least, from my point of
view. You are literally calling a function named clamav::scanBuffer(),
not the member function of the class clamav.
Hope this helps,
Nicolas Bérard Nault.
Ok, I'm in need of a sanity check here.
step one:
$input = "foo";
$scanning_class = "clamav";
$result = $scanning_class::scanBuffer($input);
now this fails with a "Parse error: parse error, unexpected
T_PAAMAYIM_NEKUDOTAYIM"So ok, you can't put variables at the front on a class call like that.
Minor bug I'm thinking at this point, but I wonder if I can work round
it. So, onto step two:
$input = "foo";
$scanning_class = "clamav";
$func = $scanning_class."::scanBuffer";
$result = $func($input);
Which fails with a "Fatal error: Call to undefined function
clamav::scanBuffer()"Just doing:
$result = clamav::scanBuffer($input);
of course works absolutly fine.Somebody just tell me that this isn't exactly expected behaviour and
it's a minor bugthis is all on 5.0.3 btw.
Cheers.
--
Gareth Ardron
Somebody just tell me that this isn't exactly expected behaviour and
it's a minor bug
This is a known limitation. I suggest using the reflection classes to
work around this.
class foo {
static function bar() {
print "static method!\n";
}
}
$class = 'foo';
$method = 'bar';
$x = new ReflectionMethod($class, $method);
$x->invoke(NULL);
-adam
--
adam@trachtenberg.com | http://www.trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!
That, I'm afraid, is expected behavior, though I believe you can use:
call_user_func(array($scanning_class,'scanBuffer'));
http://www.php.net/call_user_func
I could be wrong though
Chris
Gareth Ardron wrote:
Ok, I'm in need of a sanity check here.
step one:
$input = "foo";
$scanning_class = "clamav";
$result = $scanning_class::scanBuffer($input);
now this fails with a "Parse error: parse error, unexpected
T_PAAMAYIM_NEKUDOTAYIM"So ok, you can't put variables at the front on a class call like that.
Minor bug I'm thinking at this point, but I wonder if I can work round
it. So, onto step two:
$input = "foo";
$scanning_class = "clamav";
$func = $scanning_class."::scanBuffer";
$result = $func($input);
Which fails with a "Fatal error: Call to undefined function
clamav::scanBuffer()"Just doing:
$result = clamav::scanBuffer($input);
of course works absolutly fine.Somebody just tell me that this isn't exactly expected behaviour and
it's a minor bugthis is all on 5.0.3 btw.
Cheers.
Ok, I'm in need of a sanity check here.
step one:
$input = "foo";
$scanning_class = "clamav";
$result = $scanning_class::scanBuffer($input);
now this fails with a "Parse error: parse error, unexpected
T_PAAMAYIM_NEKUDOTAYIM"So ok, you can't put variables at the front on a class call like that.
Minor bug I'm thinking at this point, but I wonder if I can work round
it. So, onto step two:
$input = "foo";
$scanning_class = "clamav";
$func = $scanning_class."::scanBuffer";
$result = $func($input);
Which fails with a "Fatal error: Call to undefined function
clamav::scanBuffer()"Just doing:
$result = clamav::scanBuffer($input);
of course works absolutly fine.Somebody just tell me that this isn't exactly expected behaviour and
it's a minor bugthis is all on 5.0.3 btw.
Hi Gareth,
In addition to the other options people have mentioned, you could also
use the old standby of:
eval("$result = $scanning_class::scanBuffer($input);");
Regards,
Jason
http://blog.casey-sweat.us/
Jason Sweat wrote:
Hi Gareth,
In addition to the other options people have mentioned, you could also
use the old standby of:
eval("$result = $scanning_class::scanBuffer($input);");
Cheers for all the replies, people. I may have a bit of a prod at the
internals this evening though, as this is a bloody annoying thing when
you're trying to build up a highly modularised system - and I'd like the
code as clean as possible really, not jumping through hoops like use
reflection API to do this as it has to be maintained by people who
haven't yet encountered that type of thing.
Cheers,
--
Gareth Ardron
If you want to do this kind of thing, why not do it properly?
$foo = new $scanning_class;
$foo->scanBuffer($input);
that is, after all, what "extends" is all about.
--Wez
Jason Sweat wrote:
Hi Gareth,
In addition to the other options people have mentioned, you could also
use the old standby of:
eval("$result = $scanning_class::scanBuffer($input);");Cheers for all the replies, people. I may have a bit of a prod at the
internals this evening though, as this is a bloody annoying thing when
you're trying to build up a highly modularised system - and I'd like the
code as clean as possible really, not jumping through hoops like use
reflection API to do this as it has to be maintained by people who
haven't yet encountered that type of thing.Cheers,
--
Gareth Ardron
Wez Furlong wrote:
If you want to do this kind of thing, why not do it properly?
$foo = new $scanning_class;
$foo->scanBuffer($input);that is, after all, what "extends" is all about.
--Wez
hihi, that why Wez get the 'King' prefix and everyone doesn't :-)
...