Sophie

Sophie

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

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>Output a string</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.parse-str.html">parse_str</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.printf.html">printf</a></div>
 <div class="up"><a href="ref.strings.html">String Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.print" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">print</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">print</span> &mdash; <span class="dc-title">Output a string</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.print-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><strong>print</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$arg</code></span>
   )</div>

  <p class="para rdfs-comment">
   Outputs <em><code class="parameter">arg</code></em>.
  </p>
  <p class="para">
   <em>print</em> is not actually a real function (it is a
   language construct) so you are not required to use parentheses
   with its argument list.
  </p>
 </div>


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

    <dt>

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

      <p class="para">
       The input data.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.print-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <em>1</em>, always.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.print-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-4856">
    <p><strong>Example #1 <em>print</em> examples</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">print(</span><span style="color: #DD0000">"Hello&nbsp;World"</span><span style="color: #007700">);<br /><br />print&nbsp;</span><span style="color: #DD0000">"print()&nbsp;also&nbsp;works&nbsp;without&nbsp;parentheses."</span><span style="color: #007700">;<br /><br />print&nbsp;</span><span style="color: #DD0000">"This&nbsp;spans<br />multiple&nbsp;lines.&nbsp;The&nbsp;newlines&nbsp;will&nbsp;be<br />output&nbsp;as&nbsp;well"</span><span style="color: #007700">;<br /><br />print&nbsp;</span><span style="color: #DD0000">"This&nbsp;spans\nmultiple&nbsp;lines.&nbsp;The&nbsp;newlines&nbsp;will&nbsp;be\noutput&nbsp;as&nbsp;well."</span><span style="color: #007700">;<br /><br />print&nbsp;</span><span style="color: #DD0000">"escaping&nbsp;characters&nbsp;is&nbsp;done&nbsp;\"Like&nbsp;this\"."</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;You&nbsp;can&nbsp;use&nbsp;variables&nbsp;inside&nbsp;a&nbsp;print&nbsp;statement<br /></span><span style="color: #0000BB">$foo&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"foobar"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$bar&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"barbaz"</span><span style="color: #007700">;<br /><br />print&nbsp;</span><span style="color: #DD0000">"foo&nbsp;is&nbsp;</span><span style="color: #0000BB">$foo</span><span style="color: #DD0000">"</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;foo&nbsp;is&nbsp;foobar<br /><br />//&nbsp;You&nbsp;can&nbsp;also&nbsp;use&nbsp;arrays<br /></span><span style="color: #0000BB">$bar&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"value"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">);<br /><br />print&nbsp;</span><span style="color: #DD0000">"this&nbsp;is&nbsp;</span><span style="color: #007700">{</span><span style="color: #0000BB">$bar</span><span style="color: #007700">[</span><span style="color: #DD0000">'value'</span><span style="color: #007700">]}</span><span style="color: #DD0000">&nbsp;!"</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;this&nbsp;is&nbsp;foo&nbsp;!<br /><br />//&nbsp;Using&nbsp;single&nbsp;quotes&nbsp;will&nbsp;print&nbsp;the&nbsp;variable&nbsp;name,&nbsp;not&nbsp;the&nbsp;value<br /></span><span style="color: #007700">print&nbsp;</span><span style="color: #DD0000">'foo&nbsp;is&nbsp;$foo'</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;foo&nbsp;is&nbsp;$foo<br /><br />//&nbsp;If&nbsp;you&nbsp;are&nbsp;not&nbsp;using&nbsp;any&nbsp;other&nbsp;characters,&nbsp;you&nbsp;can&nbsp;just&nbsp;print&nbsp;variables<br /></span><span style="color: #007700">print&nbsp;</span><span style="color: #0000BB">$foo</span><span style="color: #007700">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;foobar<br /><br /></span><span style="color: #007700">print&nbsp;&lt;&lt;&lt;END<br /></span><span style="color: #DD0000">This&nbsp;uses&nbsp;the&nbsp;"here&nbsp;document"&nbsp;syntax&nbsp;to&nbsp;output<br />multiple&nbsp;lines&nbsp;with&nbsp;</span><span style="color: #0000BB">$variable</span><span style="color: #DD0000">&nbsp;interpolation.&nbsp;Note<br />that&nbsp;the&nbsp;here&nbsp;document&nbsp;terminator&nbsp;must&nbsp;appear&nbsp;on&nbsp;a<br />line&nbsp;with&nbsp;just&nbsp;a&nbsp;semicolon&nbsp;no&nbsp;extra&nbsp;whitespace!<br /></span><span style="color: #007700">END;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.print-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">Because this is a
language construct and not a function, it cannot be called using
<a href="functions.variable-functions.html" class="link">variable functions</a>.</span>
</p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.print-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.echo.html" class="function" rel="rdfs-seeAlso">echo</a> - Output one or more strings</span></li>
    <li class="member"> <span class="function"><a href="function.printf.html" class="function" rel="rdfs-seeAlso">printf()</a> - Output a formatted string</span></li>
    <li class="member"> <span class="function"><a href="function.flush.html" class="function" rel="rdfs-seeAlso">flush()</a> - Flush the output buffer</span></li>
    <li class="member"><a href="language.types.string.html#language.types.string.syntax.heredoc" class="link">Heredoc syntax</a></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.parse-str.html">parse_str</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.printf.html">printf</a></div>
 <div class="up"><a href="ref.strings.html">String Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>