<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.2" -->
<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/"
	>

<channel>
	<title>pootato.org &#187; PHP</title>
	<link>http://pootato.org</link>
	<description>Tutorials for your website</description>
	<pubDate>Mon, 26 May 2008 19:56:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>
	<language>en</language>
			<item>
		<title>Layout preview</title>
		<link>http://pootato.org/tutorials/php/layout-preview/</link>
		<comments>http://pootato.org/tutorials/php/layout-preview/#comments</comments>
		<pubDate>Sat, 18 Aug 2007 10:55:06 +0000</pubDate>
		<dc:creator>Clara</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://pootato.org/tutorials/php/layout-preview/</guid>
		<description><![CDATA[Ever wondered how I did the preview thing for my designs page? You&#039;ll need to do 3 pages:
- A page with your logo (keep it small),
- The page that will merge the 2 other pages,
- The page(s) with the layout preview, or anything else you want to use this script for.
Let&#039;s make the first page, [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wondered how I did the preview thing for my designs page? You&#039;ll need to do 3 pages:<br />
- A page with your logo (keep it small),<br />
- The page that will merge the 2 other pages,<br />
- The page(s) with the layout preview, or anything else you want to use this script for.</p>
<p>Let&#039;s make the first page, with your logo. I&#039;ll use mine in the example:</p>
<p><img src="http://pootato.org/images/preview.gif" alt="x" border="0" height="60" width="260" /></p>
<p>And here we go with the code:</p>
<p><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br />
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;<strong>YOUR TITLE</strong>&lt;/title&gt;<br />
&lt;meta http-equiv=&#034;Content-Type&#034; content=&#034;text/html; charset=iso-8859-1&#034;    /&gt;<br />
&lt;meta http-equiv=&#034;imagetoolbar&#034; content=&#034;false&#034; /&gt;<br />
&lt;style type=&#034;text/css&#034;&gt;<br />
body { background-color: #<em>E4EDF4</em>; background-repeat: <em>no-repeat</em>;  margin: <em>0</em>px; padding: <em>0</em>px;}<br />
&lt;/style&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;img src=&#034;<strong>LOGO-URL</strong>&#034; alt=&#034;" border=&#034;0&#034;  /&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code></p>
<p>Save this page as <strong>header.php</strong></p>
<p>Now, let&#039;s make the page that will merge the 2 others, this is where the php makes its entry. We&#039;re going to use frames.</p>
<p><code>&lt;?<br />
$siteurl = "<strong>http://your-domain.com</strong>&#034;;<br />
if ($url) {<br />
$sitedir = &#034;<strong>http://your-domain.com/layout/directory/</strong><em>$url</em>&#034;;<br />
// Don&#039;t delete $url !!!<br />
}<br />
else {<br />
header(&#034;Location: $siteurl&#034;);<br />
}<br />
?&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;<strong>YOUR TITLE</strong>&lt;/title&gt;<br />
&lt;meta http-equiv=&#034;Content-Type&#034; content=&#034;text/html; charset=iso-8859-1&#034;    /&gt;<br />
&lt;meta http-equiv=&#034;imagetoolbar&#034; content=&#034;false&#034; /&gt;<br />
&lt;/head&gt;<br />
&lt;frameset frameborder=&#034;0&#034; rows=&#034;<strong>LOGO IMAGE HEIGHT (a number)</strong>,*&#034;&gt;<br />
&lt;frame src=&#034;<strong>http://your-domain.com/</strong>header.php&#034; scrolling=&#034;no&#034;&gt;<br />
&lt;frame src=&#034;&lt;?php echo $sitedir; ?&gt;&#034;&gt;<br />
&lt;noframes&gt;<br />
&lt;body&gt;<br />
Viewing this page requires a browser capable of displaying frames.<br />
&lt;/body&gt;<br />
&lt;/noframes&gt;<br />
&lt;/frameset&gt;<br />
&lt;/html&gt;</code></p>
<p>Save this as <strong>view.php</strong> and voila!</p>
<p>Now what&#039;s left is to create your layout directory (put its url in $sitedir).    Inside that folder, create a new folder for each layout (no space!), for example:<br />
-/layout001/<br />
-/image.jpg<br />
-/index.html<br />
-/layout002/<br />
-/image.jpg<br />
-/index.html</p>
<p>Your layout page must be named <strong>index.html</strong> or .htm!</p>
<p>To make a link to the final preview page, do this:</p>
<p><code>&lt;a href="<strong>http://your-domain.com/view.php?url=layout001</strong>&#034;&gt;Preview Layout 001&lt;/a&gt;</code></p>
<p>Hope it works!</p>
<p class="akst_link"><a href="http://pootato.org/?p=105&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_105" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://pootato.org/tutorials/php/layout-preview/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Operators</title>
		<link>http://pootato.org/tutorials/php/operators/</link>
		<comments>http://pootato.org/tutorials/php/operators/#comments</comments>
		<pubDate>Wed, 15 Aug 2007 00:45:36 +0000</pubDate>
		<dc:creator>Clara</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://pootato.org/tutorials/php/operators/</guid>
		<description><![CDATA[In this tutorial, I will explain the basics of PHP operators. First you have the basics addition, subtraction, multiplication and division signs: + - * /.
 &#60;?
$x = 4;
$y = 2;
$add = $x + $y;
$sub = $x - $y;
$mul = $x * $y;
$div = $x / $y;
echo "4 + 2 = $add&#60;br /&#62;";
echo "4 - [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial, I will explain the basics of PHP operators. First you have the basics addition, subtraction, multiplication and division signs: <strong>+ - * /</strong>.</p>
<p><code> &lt;?<br />
$x = 4;<br />
$y = 2;<br />
$add = $x + $y;<br />
$sub = $x - $y;<br />
$mul = $x * $y;<br />
$div = $x / $y;<br />
echo "4 + 2 = $add&lt;br /&gt;";<br />
echo "4 - 2 = $sub&lt;br /&gt;";<br />
echo "4 * 2 = $mul&lt;br /&gt;";<br />
echo "4 / 2 = $div";<br />
?&gt; </code></p>
<p>This will display:<br />
4 + 2 = 6<br />
4 - 2 = 2<br />
4 * 2 = 8<br />
4 / 2 = 2</p>
<p>Let&#039;s see something more interesting with comparison operators. They&#039;re most used with the <em>if statement</em>.</p>
<p><strong>&lt;</strong> less than<br />
<strong>&gt;</strong> greater than<br />
<strong>&lt;=</strong> less than or equal to<br />
<strong>&gt;=</strong> greater than or equal to<br />
<strong>==</strong> equal to<br />
<strong>!=</strong> not equal to</p>
<p>With $x = 4 and $y = 2&#8230;<br />
<strong>$x == $y</strong> will return <em>false</em>;<br />
<strong>$x &gt; $y</strong> will return <em>true</em>. Etc.</p>
<p>There are also logical operators:<br />
<strong>&amp;&amp;</strong> and<br />
<strong>||</strong> or<br />
<strong>!</strong> not.</p>
<p>Still with $x = 4 and $y = 2&#8230;<br />
<strong>$x != $y &amp;&amp; $x &gt; $y</strong> will result <em>true</em>;<br />
<strong>$x == $y || $x &lt; $y</strong> will result <em>false</em>.</p>
<h2>Example</h2>
<p>Here is an example of using php operators with if statement. I use Pythagoras theorem here: in the form, fill out 2 values, y and z, the script will calculate the hypotenuse length, that is to say, y^2+z^2. <a href="#" onclick="window.open('/examples/operators/index.php','_blank','toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=250, height=100');return(false)">Try it now!</a></p>
<p>How to do it:</p>
<p><code> &lt;?<br />
if (<strong>!$y || !$z</strong>) {<br />
echo &#039;&lt;form method=&#034;post&#034; action=&#034;index.php&#034;&gt;<br />
&lt;input type=&#034;text&#034; name=&#034;y&#034; /&gt;&lt;br /&gt;<br />
&lt;input type=&#034;text&#034; name=&#034;z&#034; /&gt;&lt;br /&gt;<br />
&lt;input type=&#034;submit&#034; name=&#034;submit&#034; /&gt;<br />
&lt;/form&gt;&#039;;<br />
}<br />
else {<br />
<em>$hyp = $z * $z + $y * $y;</em><br />
echo &#039;&lt;script language=&#034;Javascript&#034; type=&#034;text/javascript&#034;&gt; alert (&#034;Your hypotenuse length is &#039;.$hyp.&#039; !&#034;) &lt;/script&gt;&#039;;<br />
} ?&gt; </code></p>
<p><strong>!$y || !$z</strong>: if there&#039;s no y or z defined, show the form, else, calculate the hypotenuse length: <em>$hyp = $z * $z + $y * $y;</em> and display it (echo). Here, I used a javascript alert to display it but you can use whatever you want!</p>
<p class="akst_link"><a href="http://pootato.org/?p=26&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_26" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://pootato.org/tutorials/php/operators/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Dynamic Inclusion subpages</title>
		<link>http://pootato.org/tutorials/php/dynamic-inclusion-subpages/</link>
		<comments>http://pootato.org/tutorials/php/dynamic-inclusion-subpages/#comments</comments>
		<pubDate>Wed, 15 Aug 2007 00:39:21 +0000</pubDate>
		<dc:creator>Clara</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://pootato.org/tutorials/php/dynamic-inclusion-subpages/</guid>
		<description><![CDATA[I merged the dynamic inclusion tutorial and Codegrrl&#039;s ConvertToPHP script. You will need to understand dynamic inclusions first. See dynamic subpages in action.
If you&#039;re already using dynamic inclusion and want to use more, here is a solution. For example, you&#039;ve already used the dynamic inclusion, so your url look like: index.php?y=page but you want to [...]]]></description>
			<content:encoded><![CDATA[<p>I merged the dynamic inclusion tutorial and Codegrrl&#039;s <a href="http://codegrrl.com/scripts/nlconverttophp/">ConvertToPHP</a> script. You will need to understand dynamic inclusions first. <a href="http://pootato.org/examples/dynamic%20subpages/">See dynamic subpages in action</a>.</p>
<p>If you&#039;re already using dynamic inclusion and want to use more, here is a solution. For example, you&#039;ve already used the dynamic inclusion, so your url look like: <samp>index.php?y=page</samp> but you want to separate the page into subpages.</p>
<p>You won&#039;t need your index.php or defaut.php/main.php here, but the page you want to divide. Let&#039;s call it page.php, you <u><strong>won&#039;t need</strong></u> any:</p>
<p><code> &lt;!DOCTYPE&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;your title&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
// CONTENTS<br />
&lt;/body&gt;<br />
&lt;/html&gt; </code></p>
<p>Since it&#039;s <u>already</u> in your index.php&#8230; open <strong>page.php</strong>, the page you want to divide and let the fun begin, paste this in the very first lines, this is your menu to navigate between the subpages.</p>
<p><code> &lt;h1&gt;Page title&lt;/h1&gt;<br />
&lt;p&gt;Select:<br />
&lt;a href="index.php?y=<strong>page</strong>&#034;&gt;back&lt;/a&gt; |<br />
&lt;a href=&#034;index.php?y=<strong>page</strong>&amp;<strong>x</strong>=1&#034;&gt;link 1&lt;/a&gt; |<br />
&lt;a href=&#034;index.php?y=<strong>page</strong>&amp;<strong>x</strong>=2&#034;&gt;link 2&lt;/a&gt; |<br />
&lt;a href=&#034;index.php?y=<strong>page</strong>&amp;<strong>x</strong>=3&#034;&gt;link 3&lt;/a&gt; |<br />
&lt;/p&gt; </code></p>
<p>A few explanations&#8230; If your document name is <strong>random</strong>.php, replace <em>page</em> by <strong>random</strong>, of course. The <strong>x</strong> means the link will look like: <samp>index.php?y=random&amp;x=value</samp>.</p>
<p>Now paste this:</p>
<p><code> &lt;?php if(!$<strong>x</strong>) { ?&gt; </code></p>
<p>Of course if you changed <samp>x</samp> by something else, don&#039;t forget to change it. Everything under that line will show up automatically if you go to <samp>index.php?y=page</samp>. Add the contents you want and when you&#039;re done, we will make the contents of <strong>link 1</strong>. Paste this after your default contents:</p>
<p><code> &lt;? } elseif ($<strong>x</strong> == &#034;<em>1</em>&#034;) { ?&gt; </code></p>
<p>Once again, if you replaced <samp>x</samp> by something else, don&#039;t forget to replace it here too. The <strong>1</strong> can be replaced by anything you want, just don&#039;t forget to change it in your menu too. Add your contents <u>after</u> that line of code. If you go to <samp>index.php?y=page</samp>, it won&#039;t show up but if you access <samp>index.php?y=page&amp;x=1</samp>, you will see these contents. When you&#039;re done adding the contents of this page, add this line:</p>
<p><code> &lt;? } elseif ($<strong>x</strong> == &#034;<em>2</em>&#034;) { ?&gt; </code></p>
<p>Same as previously, add your contents for the second page <u>under</u> that line of code. It will be accessible here: <samp>index.php?y=page&amp;x=2</samp>. A bit lost? This is what you should have in your <strong>page.php</strong></p>
<p><code> &lt;h1&gt;Page title&lt;/h1&gt;<br />
&lt;p&gt;Select:<br />
&lt;a href="index.php?y=<strong>page</strong>&#034;&gt;back&lt;/a&gt; |<br />
&lt;a href=&#034;index.php?y=<strong>page</strong>&amp;<strong>x</strong>=1&#034;&gt;link 1&lt;/a&gt; |<br />
&lt;a href=&#034;index.php?y=<strong>page</strong>&amp;<strong>x</strong>=2&#034;&gt;link 2&lt;/a&gt; |<br />
&lt;a href=&#034;index.php?y=<strong>page</strong>&amp;<strong>x</strong>=3&#034;&gt;link 3&lt;/a&gt; |<br />
&lt;/p&gt;<br />
&lt;?php if(!$<strong>x</strong>) { ?&gt;<br />
&lt;!&#8211; introduction contents, shows up when accessing index.php?y=page &#8211;&gt;<br />
&lt;? } elseif ($<strong>x</strong> == &#034;<em>1</em>&#034;) { ?&gt;<br />
&lt;!&#8211; link1 contents, shows up when accessing index.php?y=page&amp;x=1 &#8211;&gt;<br />
&lt;? } elseif ($<strong>x</strong> == &#034;<em>2</em>&#034;) { ?&gt;<br />
&lt;!&#8211; link2 contents, shows up when accessing index.php?y=page&amp;x=2 &#8211;&gt;<br />
&lt;? } elseif ($<strong>x</strong> == &#034;<em>3</em>&#034;) { ?&gt;<br />
&lt;!&#8211; link3 contents, shows up when accessing index.php?y=page&amp;x=3 &#8211;&gt;<br />
<strong>&lt;? } ?&gt;</strong></code></p>
<p>Did you notice the <samp>&lt;? } ?&gt;</samp> ? You will have to add this little code at the end of your page. You can have more than 3 subpages of course, each time your just have to add:</p>
<p><code> &lt;? } elseif ($<strong>x</strong> == &#034;<em>SUBPAGE</em>&#034;) { ?&gt;<br />
&lt;!&#8211; PAGE contents, show up when accessing index.php?y=page&amp;x=SUBPAGE &#8211;&gt; </code></p>
<p>Hope it&#039;s understandable! Don&#039;t forget you have to use dynamic inclusions first!</p>
<p>Note: There is a file embedded within this post, please visit this post to download the file.</p>
<p class="akst_link"><a href="http://pootato.org/?p=25&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_25" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://pootato.org/tutorials/php/dynamic-inclusion-subpages/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Dynamic Inclusion</title>
		<link>http://pootato.org/tutorials/php/dynamic-inclusion/</link>
		<comments>http://pootato.org/tutorials/php/dynamic-inclusion/#comments</comments>
		<pubDate>Wed, 15 Aug 2007 00:26:25 +0000</pubDate>
		<dc:creator>Clara</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://pootato.org/tutorials/php/dynamic-inclusion/</guid>
		<description><![CDATA[Important The codes have changed for security reasons. Thanks to Jem from Tutorialtastic for the codes!
This will simplify your life even more than inclusions: no header.php nor footer.php! What are dynamic inclusions? I&#039;m sure you&#039;ve already seen URLs like index.php?action=random. Let&#039;s see the structure of a basic page again:
 &#60;!DOCTYPE&#62;
&#60;html&#62;
&#60;head&#62;
&#60;title&#62;your page title&#60;/title&#62;
&#60;/head&#62;
&#60;body&#62;
// LAYOUT HEADER
// CONTENTS
// [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Important</strong> The codes have changed for security reasons. Thanks to <a href="http://www.jemjabella.co.uk/">Jem</a> from <a href="http://www.tutorialtastic.co.uk/">Tutorialtastic</a> for the codes!</p>
<p>This will simplify your life even more than inclusions: no header.php nor footer.php! What are dynamic inclusions? I&#039;m sure you&#039;ve already seen URLs like <samp>index.php?action=random</samp>. Let&#039;s see the structure of a basic page again:</p>
<p><code> &lt;!DOCTYPE&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;your page title&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
// LAYOUT HEADER<br />
// CONTENTS<br />
// LAYOUT FOOTER<br />
&lt;/body&gt;<br />
&lt;/html&gt; </code></p>
<p>You only have to remove your contents and replace it by this:</p>
<p><code> &lt;?php if (isset($_GET['<strong>x</strong>&#039;])) {<br />
if (strpos($_GET[&#039;<strong>x</strong>&#039;], &#034;/&#034;)) {<br />
$dir = substr(str_replace(&#039;..&#039;, &#034;, $_GET[&#039;<strong>x</strong>&#039;]), 0, strpos($_GET[&#039;<strong>x</strong>&#039;], &#034;/&#034;)) . &#034;/&#034;;<br />
$file = substr(strrchr($_GET[&#039;<strong>x</strong>&#039;], &#034;/&#034;), 1);<br />
if (file_exists($dir.$file.&#034;.php&#034;)) {<br />
include($dir.$file.&#034;.php&#034;);<br />
} else {<br />
include(&#034;default.php&#034;);<br />
}<br />
} else {<br />
if (file_exists(basename($_GET[&#039;<strong>x</strong>&#039;]).&#034;.php&#034;)) {<br />
include(basename($_GET[&#039;<strong>x</strong>&#039;]).&#034;.php&#034;);<br />
} else {<br />
include(&#034;default.php&#034;);<br />
}<br />
}<br />
} else {<br />
include(&#034;default.php&#034;);<br />
} ?&gt; </code></p>
<p>Save the file as <strong>index.php</strong> and this is what it looks like:</p>
<p><code> &lt;!DOCTYPE&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;your page title&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
// LAYOUT HEADER<br />
&lt;?php if (isset($_GET['<strong>x</strong>&#039;])) {<br />
if (strpos($_GET[&#039;<strong>x</strong>&#039;], &#034;/&#034;)) {<br />
$dir = substr(str_replace(&#039;..&#039;, &#034;, $_GET[&#039;<strong>x</strong>&#039;]), 0, strpos($_GET[&#039;<strong>x</strong>&#039;], &#034;/&#034;)) . &#034;/&#034;;<br />
$file = substr(strrchr($_GET[&#039;<strong>x</strong>&#039;], &#034;/&#034;), 1);<br />
if (file_exists($dir.$file.&#034;.php&#034;)) {<br />
include($dir.$file.&#034;.php&#034;);<br />
} else {<br />
include(&#034;default.php&#034;);<br />
}<br />
} else {<br />
if (file_exists(basename($_GET[&#039;<strong>x</strong>&#039;]).&#034;.php&#034;)) {<br />
include(basename($_GET[&#039;<strong>x</strong>&#039;]).&#034;.php&#034;);<br />
} else {<br />
include(&#034;default.php&#034;);<br />
}<br />
}<br />
} else {<br />
include(&#034;default.php&#034;);<br />
} ?&gt;<br />
// LAYOUT FOOTER<br />
&lt;/body&gt;<br />
&lt;/html&gt; </code></p>
<p>What about the contents? Put them in a new file, contents only! No <samp>html</samp>, <samp>head</samp> or <samp>body</samp> codes! For example:</p>
<p><code> &lt;p&gt;Welcome dear visitor!&lt;/p&gt; </code></p>
<p>Save it as <strong>default.php</strong>! If someone goes to index.php, the default.php contents will show up. What about the other contents?</p>
<p><code> &lt;p&gt;This is my about page.&lt;/p&gt; </code></p>
<p>Only the text! No design codes. Save it as <strong>about.php</strong>! Now, for example, you want to access the about page? You just have to put a link to <samp>index.php?x=about</samp> ! No need to put about.php at the end of the url. It&#039;s already defined in the code. If you want to use something other than <strong>x</strong> as a variable, replace the bolded x by whatever you like. If your contents&#039; files are .html, just change all the .php to .html :)</p>
<p>In this case, the URL will be something like: <samp>index.php?any=about</samp>. If your files are in a folder, your URL will look like this: <samp>index.php?any=folder/page</samp>.</p>
<p>Note: There is a file embedded within this post, please visit this post to download the file.</p>
<p class="akst_link"><a href="http://pootato.org/?p=24&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_24" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://pootato.org/tutorials/php/dynamic-inclusion/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Inclusion</title>
		<link>http://pootato.org/tutorials/php/inclusion/</link>
		<comments>http://pootato.org/tutorials/php/inclusion/#comments</comments>
		<pubDate>Wed, 15 Aug 2007 00:16:52 +0000</pubDate>
		<dc:creator>Clara</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://pootato.org/tutorials/php/inclusion/</guid>
		<description><![CDATA[This will simplify your life. Let&#039;s see the structure of a webpage once again:
 &#60;!--CHOOSE A DOCTYPE TO VALIDATE--&#62;
&#60;html&#62;
&#60;head&#62;
&#60;title&#62;your page title&#60;/title&#62;
&#60;/head&#62;
&#60;body&#62;
// LAYOUT HEADER
// CONTENTS
// LAYOUT FOOTER
&#60;/body&#62;
&#60;/html&#62; 
We&#039;ll want to separate the content from everything else: layout, header, footer. First, the header.
 &#60;!--CHOOSE A DOCTYPE TO VALIDATE--&#62;
&#60;html&#62;
&#60;head&#62;
&#60;title&#62;your page title&#60;/title&#62;
&#60;/head&#62;
&#60;body&#62;
// LAYOUT HEADER 
Save it as header.php and [...]]]></description>
			<content:encoded><![CDATA[<p>This will simplify your life. Let&#039;s see the structure of a webpage once again:</p>
<p><code> &lt;!--CHOOSE A DOCTYPE TO VALIDATE--&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;your page title&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
// LAYOUT HEADER<br />
// CONTENTS<br />
// LAYOUT FOOTER<br />
&lt;/body&gt;<br />
&lt;/html&gt; </code></p>
<p>We&#039;ll want to separate the content from everything else: layout, header, footer. First, the header.</p>
<p><code> &lt;!--CHOOSE A DOCTYPE TO VALIDATE--&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;your page title&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
// LAYOUT HEADER </code></p>
<p>Save it as <strong>header.php</strong> and we will now extract the footer:</p>
<p><code> // LAYOUT FOOTER<br />
&lt;/body&gt;<br />
&lt;/html&gt; </code></p>
<p>Save it as <strong>footer.php</strong> and we&#039;re almost done! We&#039;re missing an index.php page and the contents:</p>
<p><code> &lt;? <strong>include(&#034;</strong><em>header.php</em><strong>&#034;);</strong> ?&gt;<br />
// CONTENTS<br />
&lt;? <strong>include(&#034;</strong><em>footer.php</em><strong>&#034;);</strong> ?&gt; </code></p>
<p>Save it as <strong>index.php</strong>! Each time the page index.php is loaded, it will &#034;call&#034; the files header.php and footer.php! You only need to add your contents codes between the two include codes. <strong>Nothing else</strong>. No <samp>html</samp>, <samp>head</samp> or <samp>body</samp> tag since everything is <u>already</u> in header.php and footer.php!</p>
<p>That&#039;s nice but how do you make other pages? It&#039;s the same:</p>
<p><code> &lt;? <strong>include(&#034;</strong><em>header.php</em><strong>&#034;);</strong> ?&gt;<br />
// OTHER CONTENTS HERE!<br />
&lt;? <strong>include(&#034;</strong><em>footer.php</em><strong>&#034;);</strong> ?&gt; </code></p>
<p>And save as <strong>anything.php</strong>! :)</p>
<p>Note: There is a file embedded within this post, please visit this post to download the file.</p>
<p class="akst_link"><a href="http://pootato.org/?p=23&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_23" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://pootato.org/tutorials/php/inclusion/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Syntax</title>
		<link>http://pootato.org/tutorials/php/syntax/</link>
		<comments>http://pootato.org/tutorials/php/syntax/#comments</comments>
		<pubDate>Wed, 15 Aug 2007 00:10:45 +0000</pubDate>
		<dc:creator>Clara</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://pootato.org/tutorials/php/syntax/</guid>
		<description><![CDATA[PHP is a useful coding language. It will simplify your life in many ways. When you use PHP, the page extension must be .php instead of .htm! Here are three different ways to insert PHP in your page:
 &#60;?
/* php code */
?&#62;
&#60;?PHP
/* php code */
?&#62;
&#60;?php
/* php code */
?&#62; 
To display a text, you can do [...]]]></description>
			<content:encoded><![CDATA[<p>PHP is a useful coding language. It will simplify your life in many ways. When you use PHP, the page extension must be .php instead of .htm! Here are three different ways to insert PHP in your page:</p>
<p><code> <strong>&lt;?</strong><br />
/* php code */<br />
<strong>?&gt;</strong><br />
<strong>&lt;?PHP</strong><br />
/* php code */<br />
<strong>?&gt;</strong><br />
<strong>&lt;?php</strong><br />
/* php code */<br />
<strong>?&gt;</strong> </code></p>
<p>To display a text, you can do it like that:</p>
<p><code> &lt;?php <strong>echo &#034;</strong><em>PHP rocks my socks.</em><strong>&#034;</strong> ?&gt; </code></p>
<p>Copy and paste the code above, save it as test.php and upload it to your server. Go to the page url: if you can read &#034;PHP rocks my socks.&#034;, it means your server supports PHP, congrats! Pay attention to apostrophes:</p>
<p><code> &lt;?php <strong>echo &#034;</strong><em>Hey it&#039;s me</em><strong>&#034;</strong> ?&gt; </code></p>
<p>In the code above, you can leave the <samp>&#039;</samp> since you&#039;re using <samp>&#034;</samp>, however:</p>
<p><code> &lt;?php <strong>echo &#039;</strong><em>Hey it</em>\<em>&#039;s me</em><strong>&#039;</strong> ?&gt; </code></p>
<p>See? You must add \ before each apostrophe if you&#039;re using <samp>&#039;</samp>.</p>
<p>As in HTML, you can insert invisible comments in the source.</p>
<p><code> <strong>//</strong> Intructions here<br />
<strong>//</strong> Another line </code></p>
<p>But if you use <samp>//</samp>, you will have to re-add them at each line. There&#039;s an other solution:</p>
<p><code> <strong>/*</strong> This is the first line<br />
And this is the second one! <strong>*/</strong> </code></p>
<p>See? This code can be used on 2 or more lines.</p>
<p class="akst_link"><a href="http://pootato.org/?p=22&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_22" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://pootato.org/tutorials/php/syntax/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
