⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intro.sca.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Introduction</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="book.sca.html">SCA</a></div> <div class="next" style="text-align: right; float: right;"><a href="sca.setup.html">Installing/Configuring</a></div> <div class="up"><a href="book.sca.html">SCA</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="intro.sca" class="preface">  <h1 class="title">Introduction</h1>  <div class="warning"><b class="warning">Warning</b><p class="simpara">This extension is<em class="emphasis">EXPERIMENTAL</em>. The behaviour of this extension鈥攊ncludingthe names of its functions and any other documentation surrounding thisextension鈥攎ay change without notice in a future release of PHP.This extension should be used at your own risk.</p></div>  <p class="para">    SCA for PHP makes it possible for a PHP programmer to write   reusable components, which can be called in a variety of ways, with an   identical interface and with a minimum of fuss. At present   components can call each other either locally or via Web services,   but in the future it is expected that other ways will be possible. It   provides the programmer with a way of doing this which will look as   natural as possible in PHP.   </p>    <p class="para">    SCA components use phpDocumentor-style (see   http://www.phpdoc.org/) annotations to declare dependencies on   other SCA components or Web services. The SCA for PHP runtime   resolves these dependencies at runtime on behalf of the components,   and thus allows the PHP programmer to focus on the business logic   rather than on locating and obtaining references to dependencies.  </p>    <p class="para">    The SCA for PHP programming model can be extended to support a   number of service types, such as REST and Atompub. However, Web   services (more accurately, WSDL defined, SOAP/HTTP services), are   the only type currently specified.   </p>    <p class="para">    Components also use annotations to define the interface which   they expose as a service. The SCA for PHP runtime will automatically   generate WSDL from these annotations, so that an SCA component is   easily exposed as a web service. These annotations are a natural   extension to those provided by phpDocumentor. Deploying a Web   service can be as simple as placing a PHP component under the document   root of a web server.   </p>    <p class="para">    Components also use annotations to specify data structures   (expressed using XML schema complex types) which are then handled   using Service Data Objects (SDOs).   </p>    <p class="para">    A PHP script which is not an SCA component and which contains no   annotations can use the services of an SCA component. A PHP script or   component can make calls to a web service that is not an SCA component,   but using the same system of calls or annotations to obtain a   reference.  </p>  <p class="para">    First we show a single SCA component, ConvertedStockQuote   which illustrates many of the features of SCA for PHP. It has one   method,   <b>getQuote()</b>, which given a stock &quot;ticker&quot;   obtains a price quote for that stock, converted to a given currency.   We shall be using this example as a basis for explaining the SCA for PHP   throughout the rest of this document.   </p>    <p class="para">   <div class="example">    <p><b>Example #1  A sample SCA component </b></p>     <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">include&nbsp;</span><span style="color: #DD0000">"SCA/SCA.php"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;Calculate&nbsp;a&nbsp;stock&nbsp;price&nbsp;for&nbsp;a&nbsp;given&nbsp;ticker&nbsp;symbol&nbsp;in&nbsp;a&nbsp;given&nbsp;currency.<br />&nbsp;*<br />&nbsp;*&nbsp;@service<br />&nbsp;*&nbsp;@binding.soap<br />&nbsp;*/<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">ConvertedStockQuote&nbsp;</span><span style="color: #007700">{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/**<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;The&nbsp;currency&nbsp;exchange&nbsp;rate&nbsp;service&nbsp;to&nbsp;use.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@reference<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@binding.php&nbsp;../ExchangeRate/ExchangeRate.php<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">public&nbsp;</span><span style="color: #0000BB">$exchange_rate</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/**<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;The&nbsp;stock&nbsp;quote&nbsp;service&nbsp;to&nbsp;use.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@reference<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@binding.soap&nbsp;../StockQuote/StockQuote.wsdl<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">public&nbsp;</span><span style="color: #0000BB">$stock_quote</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/**<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Get&nbsp;a&nbsp;stock&nbsp;quote&nbsp;for&nbsp;a&nbsp;given&nbsp;ticker&nbsp;symbol&nbsp;in&nbsp;a&nbsp;given&nbsp;currency.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;string&nbsp;$ticker&nbsp;The&nbsp;ticker&nbsp;symbol.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;string&nbsp;$currency&nbsp;What&nbsp;currency&nbsp;to&nbsp;convert&nbsp;the&nbsp;value&nbsp;to.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@return&nbsp;float&nbsp;The&nbsp;stock&nbsp;value&nbsp;is&nbsp;the&nbsp;target&nbsp;currency.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">getQuote</span><span style="color: #007700">(</span><span style="color: #0000BB">$ticker</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$currency</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$quote&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">stock_quote</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getQuote</span><span style="color: #007700">(</span><span style="color: #0000BB">$ticker</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$rate&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">exchange_rate</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getRate</span><span style="color: #007700">(</span><span style="color: #0000BB">$currency</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;&nbsp;</span><span style="color: #0000BB">$rate&nbsp;</span><span style="color: #007700">*&nbsp;</span><span style="color: #0000BB">$quote</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>  </p>    <p class="para">    In this example, we see that an SCA component is implemented by a   script containing a PHP class and includes   <var class="filename">SCA.php</var>. The class contains a mixture of   business logic and references to other components or services. In   the illustrated   <b>getQuote()</b> method there is only business   logic, but it relies on the instance variables   <var class="varname">$stock_quote</var> and   <var class="varname">$exchange_rate</var> having been initialized.   These refer to two other components and will be initialized by the SCA   runtime with proxies for these two services, whenever this   component executes. The annotations for these two services show one   to be a local component, which will be called within the same PHP   runtime, and one to be a remote component which will be called via a   SOAP request. This component also exposes the   <b>getQuote()</b> method both locally and as a web   service, so it in turn can be called either locally or remotely.  </p> </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="book.sca.html">SCA</a></div> <div class="next" style="text-align: right; float: right;"><a href="sca.setup.html">Installing/Configuring</a></div> <div class="up"><a href="book.sca.html">SCA</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -