<?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>Chris Clarke&#039;s Blog &#187; PHP</title>
	<atom:link href="http://sorrowfulunfounded.com/tags/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://sorrowfulunfounded.com</link>
	<description>Official Weblog of Christopher Clarke</description>
	<lastBuildDate>Thu, 10 Nov 2011 04:32:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Introduction to PHP: Includes</title>
		<link>http://sorrowfulunfounded.com/blog/2009/06/11/introduction-to-php-includes/</link>
		<comments>http://sorrowfulunfounded.com/blog/2009/06/11/introduction-to-php-includes/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 12:24:29 +0000</pubDate>
		<dc:creator>Chris Clarke</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[include_once]]></category>
		<category><![CDATA[incude]]></category>
		<category><![CDATA[require]]></category>
		<category><![CDATA[require_once]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://sorrowfulunfounded.com/?p=358</guid>
		<description><![CDATA[This tutorial will introduce you to the PHP include statement, and its almost identical sibling, require. The include statement is used to insert the contents of one file into the contents of another. Usage: 1 2 3 &#60;?php include &#34;/path/to/file.php&#34;; ?&#62; The included file is essentially merged with the file in which the include takes place, [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial will introduce you to the <a href="http://au2.php.net/manual/en/function.include.php">PHP include</a> statement, and its almost identical sibling, require.</p>
<p>The include statement is used to insert the contents of one file into the contents of another.<br />
<span id="more-358"></span><br />
<strong>Usage:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">&quot;/path/to/file.php&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>The included file is essentially merged with the file in which the include takes place, and the result in effect is one file containing the contents of both.</p>
<p>For example, we have two files. One is called &#8220;functions.php&#8221;, and the other, &#8220;display.php&#8221;. We are going to include &#8220;functions.php&#8221; in to &#8220;display.php&#8221;.</p>
<p>The contents of each script will be as follows.</p>
<p><strong>functions.php:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> nice_date<span style="color: #009900;">&#40;</span><span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d/m/y'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>display.php:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'functions.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Today\'s Date is: '</span><span style="color: #339933;">,</span>nice_date<span style="color: #009900;">&#40;</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Essentially, what we are saying is that the contents of display.php should actually be:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* including functions.php */</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> nice_date<span style="color: #009900;">&#40;</span><span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d/m/y'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/* finished including functions.php */</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Today\'s Date is: '</span><span style="color: #339933;">,</span>nice_date<span style="color: #009900;">&#40;</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>and the output is as so:</p>
<blockquote><p>Today&#8217;s Date is 11/06/09.</p></blockquote>
<p>You will notice that the PHP opening and closing tags (&lt;?php and ?&gt;) were maintained.PHP automatically closes its tags before and opens them after the inclusion has taken place. This is because PHP does not assume that the file included only contained PHP, for example it may only contain HTML or CSS. </p>
<p>The code within &#8220;functions.php&#8221; was executed just as if it had been in the PHP file containing the include statement in the first place.  &#8220;display.php&#8221; has access to any methods/functions, variables and other things defined in &#8220;functions.php&#8221;, and &#8220;functions.php&#8221; has access to any of those which are specified in &#8220;display.php&#8221; or other files it might include prior to &#8220;functions.php&#8221; inclusion.</p>
<p><strong>How does the require statement differ from the include statement?</strong></p>
<p>With include, if the file does not exist, your PHP script will not halt, and will continue to execute until it reaches the end. In the case of require, the script will cease execution and a fatal error will occur if the file cannot be found. You should use require to include any file you absolutely depend on like a &#8220;config.php&#8221; file containing your database access information.</p>
<p>In usage, require only differs in the text used. It is otherwise identical to include.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">require</span> <span style="color: #0000ff;">&quot;/path/to/file.php&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>What about require_once and include_once? How are they different?</strong></p>
<p>Appending _once to either require or include will only allow the file to be included once. Future include statements referencing said file will not get included again.</p>
<p>That is the conclusion of my first tutorial &#8211; an introduction to PHP includes. If you have any questions, corrections, suggestions for tutorials, or general comments, please feel free to comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://sorrowfulunfounded.com/blog/2009/06/11/introduction-to-php-includes/feed/</wfw:commentRss>
		<slash:comments>158</slash:comments>
		</item>
		<item>
		<title>Thoughts on ColdFusion</title>
		<link>http://sorrowfulunfounded.com/blog/2009/06/11/thoughts-on-coldfusion/</link>
		<comments>http://sorrowfulunfounded.com/blog/2009/06/11/thoughts-on-coldfusion/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 15:38:56 +0000</pubDate>
		<dc:creator>Chris Clarke</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[macromedia]]></category>
		<category><![CDATA[openbluedragon]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[smith]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://sorrowfulunfounded.com/?p=349</guid>
		<description><![CDATA[One of the units I am taking this study period is Internet Design &#8211; Dynamic Environments. We have been given the choice between learning either PHP or ColdFusion. Since I&#8217;ve already been coding in PHP for a number of years, I have decided to learn ColdFusion. I was originally planning on learning Python this month, [...]]]></description>
			<content:encoded><![CDATA[<p>One of the units I am taking this study period is Internet Design &#8211; Dynamic Environments. We have been given the choice between learning either <a href="http://php.net">PHP</a> or <a href="http://adobe.com/coldfusion">ColdFusion</a>. Since I&#8217;ve already been coding in PHP for a number of years, I have decided to learn ColdFusion. I was originally planning on learning <a href="http://python.net">Python</a> this month, but I may have to put that on hold for awhile. I don&#8217;t mind learning two languages at once, but I am already learning Japanese, and have commited myself to doing some work on <a href="http://muses-success.info">Muse&#8217;s Success</a>, and regularly blogging here.</p>
<p>I started ColdFusion learning last week, and I appear to have made some decent progress. I have a basic forum working. I&#8217;m not sure how secure it is, and posts are not formatted, not even paragraphed, but I will look into that soon. Compared to when I learned PHP, I&#8217;ve made a lot more progress then I did in PHP in the time-frame of about 5 days. Many of the concepts used in one language seem to be able to be applied to another, and I&#8217;m attributing it to familiarity of the concepts that my progress has been swift.</p>
<p>Age may also have something to do with it, I was around 13, perhaps 14 when I began learning PHP and it was before I could say I had a solid grasp of HTML and CSS which certainly did not help. I remember being quite proud of myself when I was able to modify existing scripts, and archive desired effects. Even happier still, when in either late 2004 or early 2005 I was able to get my first significantly custom forum script (a <a href="http://gamefaqs.com">GameFAQs</a> spin-off) to run &#8211; not modified existing code. The main project before that was a video game database script, somewhat based on <a href="http://igamingcms.com">Vortex Portal</a> on the back-end.</p>
<p>I am a bit disappointed in myself when I realise its been approximately 5 years since I first began learning PHP, and its still the only language which I work with. I should have attempted to learn another language before now. That being said my hosting environment only supports PHP5, so I won&#8217;t be able to use a new language for anything web based without purchasing another hosting account elsewhere.</p>
<p>ColdFusion appears to encourage the mixing of presentation and business logic which I dislike. There is probably a template engine that addresses this.  I also dislike mixing both ColdFusion Markup Language, and JavaScript&#8230; I mean CFScript. I would prefer ColdFusion chose one and stuck to it. That ColdFusion works based on tags also means that I cannot produce well formatted HTML (properly indented and nested) without making my source code unreadable, so a lot of unnecessary white-space in the outputted pages is annoying.</p>
<p>Being a fan of open source, I also dislike that ColdFuson is proprietary unlike most other popular web scripting languages. I am somewhat encouraged that there are some open source implementations of CFML. They seem to be more or less compatible with what I have written so far. I wonder if that holds true for more complicated applications. Those interested in ColdFusion but who are put off by it being a proprietary product should check out either <a href="http://www.smithproject.org/">Smith</a> or <a href="http://www.openbluedragon.org/">BlueDragon</a>.</p>
<p>I&#8217;ve pointed out what I dislike, but there are also things that I like. I like the built in form validation feature. I&#8217;m not a fan of the route it takes in implementing this, but it certainly makes producing a working and secure form much quicker. I also like how ColdFusion handles databases. I was initially opposed to it, but the system appears to prevent issues with database details being exposed if the server is miss-configured and exposes the source code. I also like that I only have one interface to work with any supported database. I generally use abstraction in my PHP scripts but ColdFusion does not need this in the first place. I also like that ColdFusion&#8217;s error messages are much more useful to me then PHP&#8217;s which are rather vague in some cases.</p>
<p>I can&#8217;t see myself developing any major projects in ColdFusion, but I am putting enough effort into learning it that this unit shall expand my horizons are far as career choices go once I conclude university. I don&#8217;t think I will mind developing in ColdFusion, but will likely continue to prefer PHP, and from the looks of things Python once I get around to learning it.</p>
]]></content:encoded>
			<wfw:commentRss>http://sorrowfulunfounded.com/blog/2009/06/11/thoughts-on-coldfusion/feed/</wfw:commentRss>
		<slash:comments>581</slash:comments>
		</item>
	</channel>
</rss>

