Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 12762

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Enables the ability to use PHP functions as XSLT functions</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="xsltprocessor.importstylesheet.html">XSLTProcessor::importStylesheet</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="xsltprocessor.removeparameter.html">XSLTProcessor::removeParameter</a></div>
 <div class="up"><a href="class.xsltprocessor.html">XSLTProcessor</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="xsltprocessor.registerphpfunctions" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">XSLTProcessor::registerPHPFunctions</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.0.4)</p><p class="refpurpose"><span class="refname">XSLTProcessor::registerPHPFunctions</span> &mdash; <span class="dc-title">Enables the ability to use PHP functions as XSLT functions</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-xsltprocessor.registerphpfunctions-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><span class="type void">void</span></span>
    <span class="methodname"><strong>XSLTProcessor::registerPHPFunctions</strong></span>
    ([ <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$restrict</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   This method enables the ability to use PHP functions as XSLT functions
   within XSL stylesheets.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-xsltprocessor.registerphpfunctions-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">restrict</code></em></span>
     <dd>

      <p class="para">
       Use this parameter to only allow certain functions to be called from 
       XSLT.
      </p>
      <p class="para">
       This parameter can be either a string (a function name) or an array of
       functions.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-xsltprocessor.registerphpfunctions-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   No value is returned.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-xsltprocessor.registerphpfunctions-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-5540">
    <p><strong>Example #1 Simple PHP Function call from a stylesheet</strong></p>
    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$xml&nbsp;</span><span style="color: #007700">=&nbsp;&lt;&lt;&lt;EOB<br /></span><span style="color: #DD0000">&lt;allusers&gt;<br />&nbsp;&lt;user&gt;<br />&nbsp;&nbsp;&lt;uid&gt;bob&lt;/uid&gt;<br />&nbsp;&lt;/user&gt;<br />&nbsp;&lt;user&gt;<br />&nbsp;&nbsp;&lt;uid&gt;joe&lt;/uid&gt;<br />&nbsp;&lt;/user&gt;<br />&lt;/allusers&gt;<br /></span><span style="color: #007700">EOB;<br /></span><span style="color: #0000BB">$xsl&nbsp;</span><span style="color: #007700">=&nbsp;&lt;&lt;&lt;EOB<br /></span><span style="color: #DD0000">&lt;?xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"?&gt;<br />&lt;xsl:stylesheet&nbsp;version="1.0"&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmlns:xsl="http://www.w3.org/1999/XSL/Transform"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmlns:php="http://php.net/xsl"&gt;<br />&lt;xsl:output&nbsp;method="html"&nbsp;encoding="utf-8"&nbsp;indent="yes"/&gt;<br />&nbsp;&lt;xsl:template&nbsp;match="allusers"&gt;<br />&nbsp;&nbsp;&lt;html&gt;&lt;body&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;h2&gt;Users&lt;/h2&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;table&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsl:for-each&nbsp;select="user"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;&lt;td&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsl:value-of<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select="php:function('ucfirst',string(uid))"/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/td&gt;&lt;/tr&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/xsl:for-each&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/table&gt;<br />&nbsp;&nbsp;&lt;/body&gt;&lt;/html&gt;<br />&nbsp;&lt;/xsl:template&gt;<br />&lt;/xsl:stylesheet&gt;<br /></span><span style="color: #007700">EOB;<br /></span><span style="color: #0000BB">$xmldoc&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">DOMDocument</span><span style="color: #007700">::</span><span style="color: #0000BB">loadXML</span><span style="color: #007700">(</span><span style="color: #0000BB">$xml</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$xsldoc&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">DOMDocument</span><span style="color: #007700">::</span><span style="color: #0000BB">loadXML</span><span style="color: #007700">(</span><span style="color: #0000BB">$xsl</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$proc&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">XSLTProcessor</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$proc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">registerPHPFunctions</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$proc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">importStyleSheet</span><span style="color: #007700">(</span><span style="color: #0000BB">$xsldoc</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$proc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">transformToXML</span><span style="color: #007700">(</span><span style="color: #0000BB">$xmldoc</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div></div>

    </div>
  </p>
 </div>

 <div class="refsect1 changelog" id="refsect1-xsltprocessor.registerphpfunctions-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.1.0</td>
       <td>
        The <em><code class="parameter">restrict</code></em> parameter was added.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="xsltprocessor.importstylesheet.html">XSLTProcessor::importStylesheet</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="xsltprocessor.removeparameter.html">XSLTProcessor::removeParameter</a></div>
 <div class="up"><a href="class.xsltprocessor.html">XSLTProcessor</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>