<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PHP Magic Book - Free PHP Scripts, Tutorials and Downloads &#187; Echo</title>
	<atom:link href="http://www.phpmagicbook.com/category/echo/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpmagicbook.com</link>
	<description>PHP AtoZ Reloaded, free php tutorials, free php downloads, php scripts, PHP tips</description>
	<lastBuildDate>Tue, 15 Jun 2010 13:22:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>PHP Echo in PHP</title>
		<link>http://www.phpmagicbook.com/php-echo/</link>
		<comments>http://www.phpmagicbook.com/php-echo/#comments</comments>
		<pubDate>Thu, 19 Jun 2008 13:02:46 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[Concatenation]]></category>
		<category><![CDATA[Echo]]></category>
		<category><![CDATA[PHP Basics]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[escaping]]></category>

		<guid isPermaLink="false">http://www.phpmagicbook.com/?p=139</guid>
		<description><![CDATA[PHP function echo is a means of outputting text to the web browser. Here is how we can use echo in PHP in different ways. &#60;?php echo &#34;Hello World&#34;; ?&#62; With HTML Tags &#60;?php echo &#34;&#60;font color='#000000'&#62;Hello World&#60;/font&#62;&#34;; ?&#62; &#60;font color=&#34;green&#34;&#62; &#60;?php echo &#34;Hello World&#34;; ?&#62; &#60;/font&#62; Encoding Quotes &#8211; Escaping And Use of Apostrophe [...]<p><a href="http://www.phpmagicbook.com/php-echo/">PHP Echo in PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
]]></description>
			<content:encoded><![CDATA[<p>PHP function echo is a means of outputting text to the web browser. Here is how we can use echo in PHP in different ways.</p>
<p><span id="more-210"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hello World&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h4>With HTML Tags</h4>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;font color='#000000'&gt;Hello World&lt;/font&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;font color=&quot;green&quot;&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hello World&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/font&gt;</pre></div></div>

<h4>Encoding Quotes &#8211; Escaping And Use of Apostrophe</h4>
<p>You can output HTML with PHP. However, you must be careful when using HTML code or any other string that includes quotes! The echo function uses quotes to define the beginning and end of the string, so you must use one of the following tactics if your string contains quotations:</p>
<ul>
<li>Don&#8217;t use quotes inside your string</li>
<li>Escape your quotes that are within the string with a backslash. To escape a quote just place a backslash directly before the quotation mark, i.e. \&#8221;</li>
<li>Use single quotes (apostrophes) for quotes inside your string</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// This won't work because of the quotes around special H1.</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;h1 class=&quot;</span>someclass<span style="color: #0000ff;">&quot;&gt;Hello World!&lt;/h1&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// OK because we escaped the quotes!</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;h1 class=<span style="color: #000099; font-weight: bold;">\&quot;</span>someclass<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;Hello World!&lt;/h1&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// OK because we used an apostrophe '</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;h1 class='someclass'&gt;Hello World!&lt;/h1&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h4>Echoing Variables</h4>
<p>No quotations are required while echoing variables, even if the variable does not hold a string. Below is the correct format for echoing a variable.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Hello World.  My name is: &quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$number</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$letter</span> <span style="color: #339933;">=</span> a<span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$string</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$number</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$letter</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h4>Echoing Variables and Text Strings</h4>
<p>Variables and text strings are joined together with a period( . ). The example below shows how to do such a combination.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Hello World.  My name is: &quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$newline</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$string</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;Bobettta&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$newline</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hi, I'm micky.  Who are you? &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$string</span><span style="color: #339933;">.</span><span style="color: #000088;">$newline</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hi, I'm micky.  Who are you? &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$string</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;Bobetta&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><a href="http://www.phpmagicbook.com/php-echo/">PHP Echo in PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.phpmagicbook.com/find-page-url-php/" title="Find Page URL With PHP &#8211; File Path">Find Page URL With PHP &#8211; File Path</a></li><li><a href="http://www.phpmagicbook.com/php-string-case-capitalization/" title="PHP &#8211; String Case &#8211; Capitalization">PHP &#8211; String Case &#8211; Capitalization</a></li><li><a href="http://www.phpmagicbook.com/php-post-and-get/" title="PHP Post And Get">PHP Post And Get</a></li><li><a href="http://www.phpmagicbook.com/php-arrays/" title="PHP Arrays">PHP Arrays</a></li><li><a href="http://www.phpmagicbook.com/php-strings/" title="PHP Strings">PHP Strings</a></li><li><a href="http://www.phpmagicbook.com/local-and-glob-scope/" title="Local And Global Variable Scope in PHP">Local And Global Variable Scope in PHP</a></li><li><a href="http://www.phpmagicbook.com/php-logical-operators/" title="PHP Logical Operators">PHP Logical Operators</a></li><li><a href="http://www.phpmagicbook.com/php-functions/" title="PHP Functions">PHP Functions</a></li><li><a href="http://www.phpmagicbook.com/php-for-each-loop/" title="PHP ForEach Loop">PHP ForEach Loop</a></li><li><a href="http://www.phpmagicbook.com/php-do-while-loop/" title="PHP Do While Loop">PHP Do While Loop</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.phpmagicbook.com/php-echo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
