日期:2014-05-17  浏览次数:20422 次

十个超级有用的PHP代码片段
<p>1. 发送短信</p>
<p>调用 <a rel="nofollow" href="http://www.textmagic.com/" target="_blank">TextMagic</a>
API。</p>
<div id="highlighter_720407" class="syntaxhighlighter  ">
<div class="lines">
<div class="line alt1">
<table border="0"><tbody><tr>
<td class="number">
<code>01</code>
</td>
<td class="content">
<code class="comments">// Include the TextMagic PHP lib</code>
</td>
</tr></tbody></table>
</div>
<div class="line alt2">
<table border="0"><tbody><tr>
<td class="number">
<code>02</code>
</td>
<td class="content">
<code class="keyword">require</code>
<code class="plain">(</code>
<code class="string">'textmagic-sms-api-php/TextMagicAPI.php'</code>
<code class="plain">);</code>
</td>
</tr></tbody></table>
</div>
<div class="line alt1">
<table border="0"><tbody><tr>
<td class="number">
<code>03</code>
</td>
<td class="content">?</td>
</tr></tbody></table>
</div>
<div class="line alt2">
<table border="0"><tbody><tr>
<td class="number">
<code>04</code>
</td>
<td class="content">
<code class="comments">// Set the username and password information</code>
</td>
</tr></tbody></table>
</div>
<div class="line alt1">
<table border="0"><tbody><tr>
<td class="number">
<code>05</code>
</td>
<td class="content">
<code class="variable">$username</code>
<code class="plain">= </code>
<code class="string">'myusername'</code>
<code class="plain">;</code>
</td>
</tr></tbody></table>
</div>
<div class="line alt2">
<table border="0"><tbody><tr>
<td class="number">
<code>06</code>
</td>
<td class="content">
<code class="variable">$password</code>
<code class="plain">= </code>
<code class="string">'mypassword'</code>
<code class="plain">;</code>
</td>
</tr></tbody></table>
</div>
<div class="line alt1">
<table border="0"><tbody><tr>
<td class="number">
<code>07</code>
</td>
<td class="content">?</td>
</tr></tbody></table>
</div>
<div class="line alt2">
<table border="0"><tbody><tr>
<td class="number">
<code>08</code>
</td>
<td class="content">
<code class="comments">// Create a new instance of TM</code>
</td>
</tr></tbody></table>
</div>
<div class="line alt1">
<table border="0"><tbody><tr>
<td class="number">
<code>09</code>
</td>
<td class="content">
<code class="variable">$router</code>
<code class="plain">= </code>
<code class="keyword">new</code>
<code class="plain">TextMagicAPI(</code>
<code class="keyword">array</code>
<code class="plain">(</code>
</td>
</tr></tbody></table>