note 99315 modified in xsltprocessor.registerphpfunctions by danbrown
| From: | danbrown@php.net | Date: | Tue, 10 Aug 2010 15:02:15 +0000 |
| Subject: | note 99315 modified in xsltprocessor.registerphpfunctions by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-171521@lists.php.net to get a copy of this message | ||
Let's get the terminology correct here, folks.
If you are calling a function that is residing within a class, reference it by its INSTANCE name,
NOT its class name.
class.my_class.php:
<?php
class class_name {
static function function_name($in){
return ($out);
}
}
?>
calling_document.php:
<?php
require_once('class.my_class.php');
$instance_name=new class_name();
?>
my_xslt.xsl:
<xsl:value-of select="php:function
('instance_name::function_name','garbage')" />
BTW, in 5.1.6 double-colon (::) is the only thing that works when calling a function that resides
within a class. However, you must declare your function as static. Using -> as some have
suggested (e.g., php:function ('instance_name->function_name','garbage'))
doesn't work at all, no matter how you declare your function.
--was--
Let's get the terminology correct here, folks.
If you are calling a function that is residing within a class, reference it by its INSTANCE name,
NOT its class name.
class.my_class.php:
<?php
class class_name {
static function function_name($in){
return ($out);
}
}
?>
calling_document.php:
<?php
require_once('class.my_class.php');
$instance_name=new class_name();
?>
my_xslt.xsl:
<xsl:value-of select="php:function
('instance_name::function_name','garbage')" />
Developers, please provide better and more thorough examples for this function.
BTW, in 5.1.6 double-colon (::) is the only thing that works when calling a function that resides
within a class. However, you must declare your function as static. Using -> as some have
suggested (e.g., php:function ('instance_name->function_name','garbage'))
doesn't work at all, no matter how you declare your function.
If you can prove otherwise, please provide clear, working examples.
http://php.net/manual/en/xsltprocessor.registerphpfunctions.php