<?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>Sunny Man&#039;s Blog &#187; Programming</title>
	<atom:link href="http://blog.eop.org.uk/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.eop.org.uk</link>
	<description></description>
	<lastBuildDate>Thu, 09 Sep 2010 13:53:39 +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>3D Hill Plot with MATLAB</title>
		<link>http://blog.eop.org.uk/481-3d-hill-plot-with-matlab/</link>
		<comments>http://blog.eop.org.uk/481-3d-hill-plot-with-matlab/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 17:59:38 +0000</pubDate>
		<dc:creator>Sunny Man</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Educational]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.eop.org.uk/?p=481</guid>
		<description><![CDATA[I thought I&#8217;d share some of the easier things I had to do as part of the first year of my course. One of those tasks was to generate a 3D plot of a function and then also plot 2D cross sections at different values. We start off with a mathematical function that describes, what [...]]]></description>
			<content:encoded><![CDATA[<p>I thought I&#8217;d share some of the easier things I had to do as part of the first year of my course. One of those tasks was to generate a 3D plot of a function and then also plot 2D cross sections at different values.</p>
<p>We start off with a mathematical function that describes, what we will call, our hill. This function represents the &#8216;height&#8217; of our hill, h if you will, at the different points in x and y.</p>
<p><a href="http://blog.eop.org.uk/wp-content/uploads/2010/07/eq1.jpg"><img class="aligncenter size-full wp-image-482" title="Hill Plot Equation" src="http://blog.eop.org.uk/wp-content/uploads/2010/07/eq1.jpg" alt="exp(-(x.^2)-(y.^2)) + 0.5.*exp(-((x-2).^2)-(y.^2));" width="434" height="107" /></a></p>
<p>So, in our MATLAB script we first of all generate a grid of points using x values from -1.5 to 3.5 and y values from -2 to 2. The follow code achieves this.</p>
<p><code>x = linspace(-1.5,3.5,50); <span style="color: #ff6600;">% 50 values of x</span><br />
y = linspace(-2,2,25); <span style="color: #ff6600;">% 25 values of x</span><br />
[xg yg] = meshgrid(x,y); <span style="color: #ff6600;">% generate points</span></code></p>
<p>And next we generate the height values of our hill, using the grid we have just created with x -&gt; xg and y -&gt;yg.</p>
<p><code>h = exp(-(xg.^2)-(yg.^2)) + 0.5.*exp(-((xg-2).^2)-(yg.^2)); <span style="color: #ff6600;">% calculate height values</span></code></p>
<p>With our hight values in the array h, all we need to do now is plot them. Firstly, to create the 3D plot we just plot x,y and h using the <strong>surf()</strong> function.</p>
<p><code>figure(1); <span style="color: #ff6600;">% create new figure window</span><br />
surf(x,y,h); <span style="color: #ff6600;">% surface plot</span><br />
title('3D Hill Plot'); <span style="color: #ff6600;">% title and axis labels</span><br />
xlabel('x');<br />
ylabel('y');<br />
zlabel('height');</code></p>
<p>Now, to look at several slices through the hill at different values of y, we need to select the different values of y from its array and plot them on the same graph.</p>
<p><code>figure(2);<br />
plot(x,h([1,10,20],:)); <span style="color: #ff6600;">% plot 1st, 10th and 20th values of y</span><br />
title('2D Hill Plot'); <span style="color: #ff6600;">% title and axis labels</span><br />
xlabel('x');<br />
ylabel('height');<br />
legend('y = -1.5','y = -0.4','y = 1.2',0); <span style="color: #ff6600;">% legend not overlapping any of the plot</span></code></p>
<p>Putting it all together you get a 3D plot of the function and the cross sections in two windows. Job done.</p>
<p style="text-align: center;"><a href="http://blog.eop.org.uk/wp-content/uploads/2010/07/matlab1.jpg"><img class="aligncenter size-medium wp-image-486" title="3D Hill Plot" src="http://blog.eop.org.uk/wp-content/uploads/2010/07/matlab1-300x224.jpg" alt="" width="240" height="179" /></a><a href="http://blog.eop.org.uk/wp-content/uploads/2010/07/matlab2.jpg"><img class="aligncenter size-medium wp-image-487" title="2D Hill Cross Sections" src="http://blog.eop.org.uk/wp-content/uploads/2010/07/matlab2-300x224.jpg" alt="" width="240" height="179" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eop.org.uk/481-3d-hill-plot-with-matlab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Fractals with MATLAB</title>
		<link>http://blog.eop.org.uk/457-create-fractals-with-matlab/</link>
		<comments>http://blog.eop.org.uk/457-create-fractals-with-matlab/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 04:29:01 +0000</pubDate>
		<dc:creator>Sunny Man</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Educational]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.eop.org.uk/?p=457</guid>
		<description><![CDATA[As part of my University course we had to use the scientific MATLAB programming language, and computing environment,  for several tasks in the first year. While the set tasks were as drab and dreary as you would expect from a Physics course, it taught us the basic skills and the problem solving skills key to [...]]]></description>
			<content:encoded><![CDATA[<p>As part of my University course we had to use the scientific <a href="http://www.mathworks.com/products/matlab/">MATLAB</a> programming language, and computing environment,  for several tasks in the first year. While the set tasks were as drab and dreary as you would expect from a Physics course, it taught us the basic skills and the problem solving skills key to the course.</p>
<p>In my spare time I ported a PHP script <a href="http://cow.neondragon.net/index.php/2680-Php-Fractal-Generator">my friend</a> created to MATLAB which enables the creation of beautiful fractals from the Mandlebrot set. The maximum image size you can create depends on the amount of memory available in your system and the script isn&#8217;t something I&#8217;ve spent a lot of time on so feel free to improve on it.</p>
<p>On my laptop, a 10,000 x 10,000 pixel image took about an hour to create, using 20 iterations. You may find this differs on other machines.</p>
<p style="text-align: center;"><a href="http://blog.eop.org.uk/wp-content/uploads/2010/07/BIG.jpg"><img class="aligncenter size-medium wp-image-458" title="Example Fractal" src="http://blog.eop.org.uk/wp-content/uploads/2010/07/BIG-300x163.jpg" alt="" width="300" height="163" /></a><br />
Download the <a href="http://blog.eop.org.uk/wp-content/uploads/2010/07/fractals.txt">MATLAB Fractal Generator Code</a>.</p>
<p style="text-align: left;">
]]></content:encoded>
			<wfw:commentRss>http://blog.eop.org.uk/457-create-fractals-with-matlab/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft Silverlight (WPF/E)</title>
		<link>http://blog.eop.org.uk/354-microsoft-silverlight-wpfe/</link>
		<comments>http://blog.eop.org.uk/354-microsoft-silverlight-wpfe/#comments</comments>
		<pubDate>Mon, 16 Apr 2007 21:25:31 +0000</pubDate>
		<dc:creator>Sunny Man</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.eop.org.uk/354-microsoft-silverlight-wpfe/</guid>
		<description><![CDATA[I saw in the news yesterday that Microsoft released its competitor to Adobe&#8217;s (formerly Macromedia&#8217;s) hugely successful and widely-used Flash presentation software and ActionScript scripting language. Microsoft hopes that its Windows Presentation Foundation/Everywhere, now Silverlight, will claw some market share from Flash&#8217;s monopolistic grip on the web. Employing already established JavaScript and Microsoft&#8217;s proprietary XAML [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://blog.eop.org.uk/wp-content/uploads/2007/04/silverlight.jpg' alt='Microsoft Silverlight' class='float_l' />I saw in the news yesterday that Microsoft released its competitor to Adobe&#8217;s (formerly Macromedia&#8217;s) hugely successful and widely-used Flash presentation software and ActionScript scripting language. Microsoft hopes that its Windows Presentation Foundation/Everywhere, now <a href="http://www.microsoft.com/silverlight/">Silverlight</a>, will claw some market share from Flash&#8217;s monopolistic grip on the web. Employing already established JavaScript and Microsoft&#8217;s proprietary <abbr title="eXtensible Application Markup Language">XAML</abbr> language, Silverlight would seem to be something to watch, even at this early stage. Today I decided to take a go at it and see if even I could use it. I&#8217;ve had limited experience with ActionScript and <abbr title="eXtensible Markup Language">XML</abbr> so I wanted to to compare it to my previous experiences. Here&#8217;s how I got on.</p>
<p><em>Before you read on, to view the things I&#8217;ve made, go to the <a href="http://www.microsoft.com/silverlight/downloads.aspx">download page</a> and download the cross-browser plugin.</em></p>
<h5>Silverlight Basics</h5>
<p>I&#8217;m not going to turn this into a tutorial on how to setup everything &#8211; it can all be found in the official SDK, also available on the download page &#8211; but I will show the XAML and relevant JavaScript files that accompany each of the things I am to show.</p>
<p>The SDK&#8217;s quickstart guide was a really simple and easy explanation of the process of creating very simple shapes at first. I was a little confused at first because the XAML files I create utilise the canvas tag and initially I got it mixed up with the HTML tag of the same name. Firstly you create the canvas you&#8217;re going to &#8216;draw&#8217; in. [Nearly] everything else goes inside this. The layers on the canvas, or z-index, are defined by the order the objects are created &#8211; those created later on in the script are on the top layers.</p>
<p>My first foray into it was a simple monochrome target which just created several ellipses in each other with the smallest one having a border instead of a fill. Here&#8217;s the <strong>.xaml</strong> file:</p>
<pre lang="xml"><Canvas xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Background="transparent">

  <Ellipse Height="200" Width="200"
        Canvas.Left="0" Canvas.Top="0"
	Fill="#000" />
  <Ellipse Height="180" Width="180"
        Canvas.Left="10" Canvas.Top="10"
	Fill="#fff" />
  <Ellipse Height="160" Width="160"
        Canvas.Left="20" Canvas.Top="20"
	Fill="#000" />
  <Ellipse Height="140" Width="140"
        Canvas.Left="30" Canvas.Top="30"
	Fill="#fff" />
  <Ellipse Height="120" Width="120"
        Canvas.Left="40" Canvas.Top="40"
	Stroke="Black" StrokeThickness="10" />

</Canvas></pre>
<p>You can view the example&#8217;s <a href="http://eop.org.uk/stuff/silverlight/example1.html">finished product</a> if you have the <a href="http://www.microsoft.com/silverlight/downloads.aspx">plugin</a> installed.</p>
<h5>Using Images</h5>
<p>Next I did a bit of playing around with images. There are several ways you can use images on your canvas which include using them as a filling for an object or importing them on their own. In this example, I&#8217;ve created a rectangle and used an image of a pound coin and then overlayed it with 4 rectangles of differing colours with an opacity set. Along side it, I&#8217;ve added a gradient overlay to the image.</p>
<pre lang="xml"><Canvas
    xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Background="transparent">

   <Rectangle Height="240" Width="320"
		Canvas.Left="0" Canvas.Top="0"
		Stroke="Black" StrokeThickness="1">
    <Rectangle.Fill>
      <ImageBrush ImageSource="bg2.jpg" Stretch="Uniform"/>
    </Rectangle.Fill>
  </Rectangle>

	<Rectangle Height="120" Width="160"
		Canvas.Left="0" Canvas.Top="0"
		Fill="#ff0" Opacity="0.3" />
	<Rectangle Height="120" Width="160"
		Canvas.Left="160" Canvas.Top="0"
		Fill="#03f" Opacity="0.3" />
	<Rectangle Height="120" Width="160"
		Canvas.Left="0" Canvas.Top="120"
		Fill="#f00" Opacity="0.3" />
	<Rectangle Height="120" Width="160"
		Canvas.Left="160" Canvas.Top="120"
		Fill="#6c0" Opacity="0.3" />
	<Ellipse Height="90" Width="90" Fill="#fff"
		Canvas.Top="75" Canvas.Left="115"
		Opacity="0.5" />

   <Rectangle Height="240" Width="320"
		Canvas.Left="350" Canvas.Top="0"
		Stroke="Black" StrokeThickness="1">
    <Rectangle.Fill>
      <ImageBrush ImageSource="bg2.jpg" Stretch="Uniform"/>
    </Rectangle.Fill>
    <Rectangle.OpacityMask>
      <LinearGradientBrush>
        <GradientStop Offset="0" Color="#00000000"/>
        <GradientStop Offset="1" Color="#FF000000"/>
      </LinearGradientBrush>
    </Rectangle.OpacityMask>
  </Rectangle>
</Canvas></pre>
<p>You can view the example&#8217;s <a href="http://eop.org.uk/stuff/silverlight/example2.html">finished product</a> if you have the <a href="http://www.microsoft.com/silverlight/downloads.aspx">plugin</a> installed.</p>
<h5>Adding Multimedia</h5>
<p>Adding media like music and video is incredibly easy for beginners to grasp. A single deceleration is used for both music as well as video which is rather handy. Controlling the media object is also incredibly easy and my quick look over the documentation for the <strong>MediaElement</strong> object showed a lot of options are available for controlling it. Firstly I tried just simply embedding a sound:</p>
<pre lang="xml"><MediaElement x:Name="media" Source="music.mp3" /></pre>
<p>Next, I added the parameter to stop it automatically playing when loaded and added the controls for stop, pause and play the file. These controls also work with video media, as shown in the quick start guide provided in the SDK. The code involved this XAML code and the following JavaScript.</p>
<pre lang="xml"><!-- Stops media playback.-->
  <Canvas MouseLeftButtonDown="javascript:media_stop"
    Canvas.Left="10" Canvas.Top="500">
    <Rectangle Stroke="Black"
       Height="30" Width="55" RadiusX="5" RadiusY="5">
      <Rectangle.Fill>
        <RadialGradientBrush GradientOrigin="0.75,0.25">
          <GradientStop Color="Orange" Offset="0.0" />
          <GradientStop Color="Red" Offset="1.0" />
        </RadialGradientBrush>
      </Rectangle.Fill>
    </Rectangle>
    <TextBlock Canvas.Left="5" Canvas.Top="5">stop</TextBlock>
  </Canvas>

  <!-- Pauses media playback. -->
  <Canvas MouseLeftButtonDown="javascript:media_pause"
     Canvas.Left="70" Canvas.Top="500">
    <Rectangle Stroke="Black"
       Height="30" Width="55" RadiusX="5" RadiusY="5">
      <Rectangle.Fill>
        <RadialGradientBrush GradientOrigin="0.75,0.25">
          <GradientStop Color="Yellow" Offset="0.0" />
          <GradientStop Color="Orange" Offset="1.0" />
        </RadialGradientBrush>
      </Rectangle.Fill>
    </Rectangle>
    <TextBlock Canvas.Left="5" Canvas.Top="5">pause</TextBlock>
  </Canvas>

  <!-- Begins media playback. -->
  <Canvas MouseLeftButtonDown="javascript:media_begin"
    Canvas.Left="130" Canvas.Top="500">
    <Rectangle Stroke="Black" RadiusX="5" RadiusY="5"
       Height="30" Width="55">
      <Rectangle.Fill>
        <RadialGradientBrush GradientOrigin="0.75,0.25">
          <GradientStop Color="LimeGreen" Offset="0.0" />
          <GradientStop Color="Green" Offset="1.0" />
        </RadialGradientBrush>
      </Rectangle.Fill>
    </Rectangle>
    <TextBlock Canvas.Left="10" Canvas.Top="5">play</TextBlock>
  </Canvas></pre>
<p>And this JavaScript, inserted either in the head of the page or an external JavaScript file:</p>
<pre lang="javascript"><script type="text/javascript">
	function media_stop(sender, args) {
		sender.findName("media").stop();
	}
	function media_pause(sender, args) {
		sender.findName("media").pause();
	}
	function media_begin(sender, args) {
		sender.findName("media").play();
	}
</script></pre>
<p>You can view the example&#8217;s <a href="http://eop.org.uk/stuff/silverlight/example3.html">finished product</a> if you have the <a href="http://www.microsoft.com/silverlight/downloads.aspx">plugin</a> installed. Click the play, pause and stop buttons to test it out.</p>
<h5>Lighting up the web?</h5>
<p>Obviously I have to take into account the infancy in terms of development of Silverlight but it&#8217;s wide array of features is quite appealing. It took me a quarter of the time to stream a video in Silverlight than it did to do it manually in Flash via ActionScript. At the moment, Silverlight isn&#8217;t anywhere near Flash in terms of functionality but even at this early stage it does have some advantages over Flash in terms of the time saving it allows.</p>
<p><img src='http://blog.eop.org.uk/wp-content/uploads/2007/04/silverlight1.jpg' alt='Silverlight Promotional Image' class='float_r' />I&#8217;ve quite enjoyed doing some stuff in it and I&#8217;m sure that the abilities of Silverlight go far beyond drawing circles and streaming media. One nice example of the capabilities is this <a href="http://channel9.msdn.com/playground/wpfe/PageTurn/default.html">page turning</a> program and this <a href="http://channel9.msdn.com/playground/wpfe/wpfepad/">interactive WYSIWYG editor</a>. For me it still feels like it&#8217;s a glorified version of the HTML canvas element with some JavaScript added. It doesn&#8217;t feel smooth like Flash and currently feels slightly buggy and laggy but I hope this will change in future revisions.</p>
<p>I&#8217;ve enjoyed using HTML, XAML and JavaScript and I think that it will eventually catch on &#8211; if it doesn&#8217;t then Microsoft will probably force it on us in some way. At the moment the plugin is available for both Windows and OSX but I hope Microsoft don&#8217;t make the mistake Adobe made by not keeping the Linux community up to date. Try it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eop.org.uk/354-microsoft-silverlight-wpfe/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP Lesson 8</title>
		<link>http://blog.eop.org.uk/349-php-lesson-8/</link>
		<comments>http://blog.eop.org.uk/349-php-lesson-8/#comments</comments>
		<pubDate>Wed, 14 Feb 2007 12:16:31 +0000</pubDate>
		<dc:creator>Sunny Man</dc:creator>
				<category><![CDATA[Educational]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.eop.org.uk/349-php-lesson-8/</guid>
		<description><![CDATA[My lessons are now into their second week and we’ve still got a way to go yet. This week we will be looking into IF and WHILE statements, $_GET, $_POST and we’ll also look into arrays near the end of the week. Yesterday we did a simple lesson on $_GET and how to get values [...]]]></description>
			<content:encoded><![CDATA[<p><img class="float_l" src='http://blog.eop.org.uk/wp-content/uploads/2007/02/tutorials.jpg' alt='Sunny Man’s Tutorials' />My lessons are now into their second week and we’ve still got a way to go yet. This week we will be looking into IF and WHILE statements, $_GET, $_POST and we’ll also look into arrays near the end of the week.</p>
<p><a href="http://blog.eop.org.uk/348-php-lesson-7/">Yesterday</a> we did a simple lesson on $_GET and how to get values from a URL. Today another simple lesson on $_POST and the confusion that comes with it. I introduced you to $_POST in last Friday&#8217;s big special and today we are going into much more detail.</p>
<h5>Lesson 8: $_POST and Forms</h5>
<p>As I showed in Friday&#8217;s round up, we use $_POST to collect the values of submitted form data. Some confusion that I had for a while was whether or not to use the <strong>name</strong> or <strong>id</strong> attribute in the form fields to let $_POST work. I&#8217;ll settle this now &#8211; for $_POST to collect the data from the form fields, you need to assign a name attribute to them. The <strong>id</strong> can be used for labels, <abbr title="Cascading Style Sheets">CSS</abbr> classes and other things. Here&#8217;s a sample form <strong>form.php</strong>:</p>
<p><code>&lt;form action="process.php" method="post"&gt;<br />
First Name: &lt;input type="text" name="fname" size="25" /&gt;<br />
Last Name: &lt;input type="text" name="lname" size="25" /&gt;<br />
Over 16? &lt;input type="radio" name="age" value="1" /&gt; Yes &lt;input type="radio" name="age" value="0" /&gt; No<br />
&lt;input type="submit" value="submit form" /&gt;<br />
&lt;/form&gt;</code></p>
<p>In the above form we would get 3 values returned through $_POST. These would be the first name, last name and over 16 values. Here&#8217;s how we&#8217;d capture these values. This file would be <strong>process.php</strong>, as determined in the form&#8217;s first line:</p>
<p><code>&lt;?php<br />
$fname = $_POST['fname'];<br />
$lname = $_POST['lname'];<br />
$age = $_POST['age']; <span style="color:#0cf;">//either 1 or 0</span><br />
<br />$name = $fname." ".$lname; <span style="color:#0cf;">//stitch the first and last names together</span><br />
?&gt;</code></p>
<p>Pretty simple to get the form fields&#8217; values. On Friday we are going to combine everything and a lot of form fields to create a signup form which will include this, arrays and a bit of validation.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eop.org.uk/349-php-lesson-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Lesson 7</title>
		<link>http://blog.eop.org.uk/348-php-lesson-7/</link>
		<comments>http://blog.eop.org.uk/348-php-lesson-7/#comments</comments>
		<pubDate>Tue, 13 Feb 2007 18:34:47 +0000</pubDate>
		<dc:creator>Sunny Man</dc:creator>
				<category><![CDATA[Educational]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.eop.org.uk/348-php-lesson-7/</guid>
		<description><![CDATA[My lessons are now into their second week and we’ve still got a way to go yet. This week we will be looking into IF and WHILE statements, $_GET, $_POST and we’ll also look into arrays near the end of the week. In the previous lesson we went into detail about IF and WHILE statements [...]]]></description>
			<content:encoded><![CDATA[<p><img class="float_l" src='http://blog.eop.org.uk/wp-content/uploads/2007/02/tutorials.jpg' alt='Sunny Man’s Tutorials' />My lessons are now into their second week and we’ve still got a way to go yet. This week we will be looking into IF and WHILE statements, $_GET, $_POST and we’ll also look into arrays near the end of the week.</p>
<p>In the <a href="http://blog.eop.org.uk/345-php-lesson-6/">previous lesson</a> we went into detail about IF and WHILE statements and in Friday&#8217;s big round up I introduced you to $_POST and $_GET. Today we&#8217;re going to look further at $_GET and what it&#8217;s used for.</p>
<h5>Lesson 7: $_GET and URLs</h5>
<p>When we have a URL that includes the values of certain variables, we can use this to get the values. Say we had a URL like this:</p>
<p><code>http://www.eop.org.uk/index.php?name=sunny%20man&#038;cool=yes</code></p>
<p>We use $_GET to grab the values of the <em>name</em> and <em>cool</em> variables. Obviously this isn&#8217;t a secure way to transport variables around your site &#8211; we&#8217;ll look at a more secure way later on into the tutorials &#8211; this is the most simple way.</p>
<p><code>&lt;?php<br />
$name = $_GET['name']; <span style="color:#0cf;">//$name = "sunny man"</span><br />
$cool = $_GET['cool']; <span style="color:#0cf;">//$cool = "yes"</span><br />
?&gt;</code></p>
<p>Tomorrow I&#8217;ll be talking about $_POST and how it can be confusing when to use the name and id attributes on form field inputs.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eop.org.uk/348-php-lesson-7/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Lesson 6</title>
		<link>http://blog.eop.org.uk/345-php-lesson-6/</link>
		<comments>http://blog.eop.org.uk/345-php-lesson-6/#comments</comments>
		<pubDate>Mon, 12 Feb 2007 10:25:37 +0000</pubDate>
		<dc:creator>Sunny Man</dc:creator>
				<category><![CDATA[Educational]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.eop.org.uk/345-php-lesson-6/</guid>
		<description><![CDATA[My lessons are now into their second week and we&#8217;ve still got a way to go yet. This week we will be looking into IF and WHILE statements, $_GET, $_POST and we&#8217;ll also look into arrays near the end of the week. As always we will find a useful example we can apply everything to [...]]]></description>
			<content:encoded><![CDATA[<p><img class="float_l" src='http://blog.eop.org.uk/wp-content/uploads/2007/02/tutorials.jpg' alt='Sunny Man’s Tutorials' />My lessons are now into their second week and we&#8217;ve still got a way to go yet. This week we will be looking into IF and WHILE statements, $_GET, $_POST and we&#8217;ll also look into arrays near the end of the week.</p>
<p>As always we will find a useful example we can apply everything to at the end of the week as well as introducing some things we are going to look at in the following week. I hope you&#8217;ve learnt something in the previous week but don&#8217;t worry we will get more advanced as time goes on.</p>
<h5>Lesson 6: IF and WHILE</h5>
<p>In last week&#8217;s final day lesson I introduced you to an IF statement. I&#8217;m going to go over them in more detail today as well as introducing you to a WHILE loop. Here&#8217;s the IF statement I used in Friday&#8217;s example:</p>
<p><code>if ($username == "username" &#038;&#038; $password == "password") {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...<br />
}</code></p>
<p>This says: <em>if $username&#8217;s value is &#8220;username&#8221; and if $password&#8217;s value is &#8220;password&#8221; then do this&#8230;</em> If the statement in the <strong>( )</strong> brackets are true then it executes the instructions within the <strong>{ }</strong> brackets.</p>
<p>There are a variety of comparison operators that you can use. The one used in the example is <strong>==</strong> which means equal to. There is also <strong>!=</strong> &#8211; not equal to, <strong>===</strong> &#8211; exactly equal and of the same type, <strong>!==</strong> not exactly equal and not of the same type, <strong>&gt;</strong> &#8211; is bigger than, <strong>&lt;</strong> &#8211; is smaller than, <strong>&gt;=</strong> &#8211; is bigger than or equal to, <strong>&lt;=</strong> &#8211; is smaller than or equal to.</p>
<p>If you want to check more than one thing in an IF statement then you need to use logical operators, such as in the example I&#8217;ve used <strong>&#038;&#038;</strong> to indicate that the statement should be true if the username <strong>and</strong> the password are both correct. Here are some examples:</p>
<p><code>if ($username || $password) { ... } <span style="color:#0cf;">// OR</span><br />
if (!$username) { ... } <span style="color:#0cf;">// NOT</span><br />
if ($username XOR $password) { ... } <span style="color:#0cf;">// XOR (exclusive OR)</span></code></p>
<p>Now we have got the hard bit out of the way we can now look at WHILE statements. WHILE statements are a little different to IF statements because they perform the instructions inside the <strong>{ }</strong> brackets while a comparison remains true.</p>
<p><code>&lt;?php<br />
$a = 1;<br />
$b = 5;<br />
<br />while ($a &lt; $b) { <span style="color:#0cf;">//while $a is less than $b</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $a;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$a++; <span style="color:#0cf;">//increment $a by 1</span><br />
}<br />
?&gt;</code></p>
<p>WHILE loops come in very handy sometimes &#8211; for example when we look at arrays we will use a WHILE loop to good effect. A famous example of using &#8216;the loop&#8217; is the WordPress blogging system. This is the basic form of IF and WHILE loops. Remember them!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eop.org.uk/345-php-lesson-6/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP Lesson 5</title>
		<link>http://blog.eop.org.uk/344-php-lesson-5/</link>
		<comments>http://blog.eop.org.uk/344-php-lesson-5/#comments</comments>
		<pubDate>Fri, 09 Feb 2007 19:18:30 +0000</pubDate>
		<dc:creator>Sunny Man</dc:creator>
				<category><![CDATA[Educational]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.eop.org.uk/344-php-lesson-5/</guid>
		<description><![CDATA[Well we&#8217;ve reached the end of week one of my series of lessons on PHP. We are going to incorporate everything we have learnt in lessons one, two, three and four. In today&#8217;s lesson we&#8217;re going to create a login script in PHP and you&#8217;ll see all you&#8217;ve learnt in it as well as some [...]]]></description>
			<content:encoded><![CDATA[<p><img class="float_l" src='http://blog.eop.org.uk/wp-content/uploads/2007/02/tutorials.jpg' alt='Sunny Man’s Tutorials' />Well we&#8217;ve reached the end of week one of my series of lessons on PHP. We are going to incorporate everything we have learnt in lessons <a href="http://blog.eop.org.uk/336-php-lesson-1/">one</a>, <a href="http://blog.eop.org.uk/338-php-lesson-2/">two</a>, <a href="http://blog.eop.org.uk/339-php-lesson-3/">three</a> and <a href="http://blog.eop.org.uk/342-php-lesson-4/">four</a>.</p>
<p>In today&#8217;s lesson we&#8217;re going to create a login script in PHP and you&#8217;ll see all you&#8217;ve learnt in it as well as some new things that we are going to cover in next week&#8217;s lessons &#8211; 6 to 9. Enjoy and try it out yourself on your own server. We will take another look at this script later on and implement a mySQL connection into the script &#8211; but don&#8217;t worry about this until later.</p>
<h5>Lesson 5: Simple Login Script</h5>
<p>First of all we will take the simple username and password form from lesson 4 and use this. This will be our <strong>login.php</strong> file. Here it is again:</p>
<p><code>&lt;form action="process.php" method="post"&gt;<br />
Username: &lt;input type="text" name="username" size="25" /&gt;<br />
Password: &lt;input type="password" name="password" size="25" /&gt;<br />
&lt;input type="submit" value="submit form" /&gt;<br />
&lt;/form&gt;</code></p>
<p>Now we&#8217;ll extend this with some extra PHP code which will be used to display any error messages if the user inputs an invalid username or password. This will be added above the form code.</p>
<p><code>&lt;?php<br />
if($_GET['e']) {<br />
        $error = "Wrong username or password. Please try again.";<br />
}<br />
<br />if($error) {<br />
        ?&gt;<br />
        &lt;p style="padding:10px;border:red;color:black;"&gt;<br />
        &lt;?php echo $error; ?&gt;<br />
        &lt;/p&gt;<br />
        &lt;?php<br />
}<br />
?&gt;</code></p>
<p>Okay so now we can create the <strong>process.php</strong> file which will digest the submitted form data. Take a look at the file and go over the previous four lessons to see what you can remember how to do.</p>
<p><code>&lt;?php<br />
$username = $_POST['username'];<br />
$password = $_POST['password'];<br />
<br />if(!$username || !$password) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;header("Location:login.php?e=1");<br />
}<br />
else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($username == "username" &#038;&#038; $password == "password") {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;header("Location:members.php");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;header("Location:login.php?e=1");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
?&gt;</code></p>
<p>There may be things in there you don&#8217;t understand just yet but I assure you we&#8217;ll get to them. IF statements, $_GET global and some other things are what we&#8217;re going to visit in next week&#8217;s tutorials. When we&#8217;ve learnt functions and mySQL connections we will revisit this form and make it more dynamic. Hope you enjoyed these extremely simple and basic tutorials. See you next week.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eop.org.uk/344-php-lesson-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Lesson 4</title>
		<link>http://blog.eop.org.uk/342-php-lesson-4/</link>
		<comments>http://blog.eop.org.uk/342-php-lesson-4/#comments</comments>
		<pubDate>Thu, 08 Feb 2007 09:03:31 +0000</pubDate>
		<dc:creator>Sunny Man</dc:creator>
				<category><![CDATA[Educational]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.eop.org.uk/342-php-lesson-4/</guid>
		<description><![CDATA[Previously we looked at some of the methods PHP offers to sort and manipulate strings and we specifically looked at str_replace() and encryption methods like md5() and sha1(). In this lesson, the final one before a big project, we&#8217;re going to take a look at how to capture inputs from form fields. Also I&#8217;m going [...]]]></description>
			<content:encoded><![CDATA[<p><img class="float_l" src='http://blog.eop.org.uk/wp-content/uploads/2007/02/tutorials.jpg' alt='Sunny Man’s Tutorials' /><a href="http://blog.eop.org.uk/339-php-lesson-3/">Previously</a> we looked at some of the methods PHP offers to sort and manipulate strings and we specifically looked at <strong>str_replace()</strong> and encryption methods like <strong>md5()</strong> and <strong>sha1()</strong>.</p>
<p>In this lesson, the final one before a big project, we&#8217;re going to take a look at how to capture inputs from form fields. Also I&#8217;m going to talk about the secure and insecure ways to transfer the data.</p>
<h5>Lesson 4: Form Field Input</h5>
<p>Getting the input from a form is pretty simple and in this lesson we are going to keep it that way by using two files: <strong>form.php</strong> and <strong>process.php</strong>. The first will contain the form we are going to create which a user will fill in. The latter file will take the input, process it and output it.</p>
<p>Here&#8217;s the sample form we&#8217;re going to use. In this case it&#8217;s just a simple username and password form. This form does not validate and is in no way conforming to accessibility either.</p>
<p><code>&lt;form action="process.php" method="post"&gt;<br />
Username: &lt;input type="text" name="username" size="25" /&gt;<br />
Password: &lt;input type="password" name="password" size="25" /&gt;<br />
&lt;input type="submit" value="submit form" /&gt;<br />
&lt;/form&gt;</code></p>
<p>Once the user submits the information by the button they&#8217;ll be taken to <strong>process.php</strong> along with the values of the form fields. We use the <strong>$_POST</strong> global to take the form values. For example if we wanted to take the value of the username field and assign it to <em>$username</em>:</p>
<p><code>$username = $_POST['username'];<br />
<span style="color:#0cf;">//getting the value of the form field with the name of 'username'</span></code></p>
<p>The variable in between the square brackets refers to the <em>name=&#8221;"</em> part of the inputs in the form. So now we can create the <strong>process.php</strong> file from what we&#8217;ve learned.</p>
<p><code>&lt;?php<br />
$username = $_POST['username'];<br />
$password = $_POST['password'];<br />
<br />echo "You're username is ".$username." and your password is ".$password.".";<br />
?&gt;</code></p>
<p>So there is the simple way to collect and assign form variables sent over pages. The next lesson, lesson 5, is where we are going to put all we&#8217;ve learnt from lessons 1 to 4 into practise. You&#8217;ll use what you&#8217;ve learnt and some new stuff that will introduce you to lessons 6 to 9. Learn it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eop.org.uk/342-php-lesson-4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Lesson 3</title>
		<link>http://blog.eop.org.uk/339-php-lesson-3/</link>
		<comments>http://blog.eop.org.uk/339-php-lesson-3/#comments</comments>
		<pubDate>Wed, 07 Feb 2007 07:56:56 +0000</pubDate>
		<dc:creator>Sunny Man</dc:creator>
				<category><![CDATA[Educational]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.eop.org.uk/339-php-lesson-3/</guid>
		<description><![CDATA[In lesson 2 we touched on variables in PHP and how to create one and then change it via a number of processes. Today we&#8217;re going to use some of the functions that PHP provide which allow us to manipulate and query strings and that will most likely become very handy in the future. If [...]]]></description>
			<content:encoded><![CDATA[<p><img class="float_l" src='http://blog.eop.org.uk/wp-content/uploads/2007/02/tutorials.jpg' alt='Sunny Man’s Tutorials' />In <a href="http://blog.eop.org.uk/338-php-lesson-2/">lesson 2</a> we touched on variables in PHP and how to create one and then change it via a number of processes. Today we&#8217;re going to use some of the functions that PHP provide which allow us to manipulate and query strings and that will most likely become very handy in the future.</p>
<p>If you wish to take a look at the functions it offers then head on over to the <a href="http://uk.php.net/manual/en/ref.strings.php">PHP Manual</a>, specifically the string functions.</p>
<h5>Lesson 3: String Functions</h5>
<p>Last week we touched on how to find the length of a string using the <strong>strlen()</strong> function. Today we&#8217;re going to look at a few more functions and put them into a practical example. To find the length of a string all we have to do is employ this function as is shown here:</p>
<p><code>&lt;?php<br />
$five = strlen("mouse"); <span style="color:#0cf;">//$five's value is 5</span><br />
$word = "mousemat";<br />
$eight = strlen($word); <span style="color:#0cf;">//$eight's value is 8</span><br />
?&gt;</code></p>
<p>Now we&#8217;re going to look at replacing characters or phrases within a string with something else. To do this in the simplest way we are going to use the <strong>str_replace()</strong> function. There&#8217;s several <strong>parameters</strong> to this function. This means that we have to provide more information within the functions. In this case the format is <strong>str_replace(</strong><em>string to search for</em>, <em>string to replace it with</em>, <em>string to search within</em><strong>)</strong>.</p>
<p><code>$string = "Sunny Man’s Blog";<br />
$string = str_replace("Man","Boy",$string); <span style="color:#0cf;">//replace 'Man' with 'Boy'</span><br />
echo $string; <span style="color:#0cf;">//displays Sunny Boy's Blog</span></code></p>
<p>Later on when we get to talking about SQL and databases you&#8217;ll need to be able to encrypt strings. There are several different types of encryption available in PHP. All of them are simple enough to use but, as we will will discuss later on, knowing when to use the correct one is vital. First let&#8217;s take a look at the different types.</p>
<p><code>$password = md5("password");<br />
echo $password; <span style="color:#0cf;">//5F4DCC3B5AA765D61D8327DEB882CF99</span><br />
<br />$password = sha1("password");<br />
echo $password; <span style="color:#0cf;">//5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8</span></code></p>
<p>Both md5 and sha1 have their advantages and disadvantages but they&#8217;re both quick to generate and once stored in a variable, easy to remember. Say we wanted to take a raw password that was given to us by a form (we&#8217;ll cover this soon), replace the letter &#8216;i&#8217; with &#8216;z&#8217; and encrypt it for storage in a database, this is how we would do it:</p>
<p><code>&lt;?php<br />
$password = "birmingham";<br />
$password = str_replace("i","z",$password);<br />
$password = md5($password);<br />
?&gt;</code></p>
<p>This is the end of lesson 3. In the next lesson we&#8217;ll talk about taking variables from a form, collecting them and manipulating them in a real life situation. After than we&#8217;re going to put all we&#8217;ve learnt into a logging in script in lesson 5 which will introduce you to salts, database queries and some other stuff we will cover in lessons 6 to 10.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eop.org.uk/339-php-lesson-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Lesson 2</title>
		<link>http://blog.eop.org.uk/338-php-lesson-2/</link>
		<comments>http://blog.eop.org.uk/338-php-lesson-2/#comments</comments>
		<pubDate>Tue, 06 Feb 2007 08:03:30 +0000</pubDate>
		<dc:creator>Sunny Man</dc:creator>
				<category><![CDATA[Educational]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.eop.org.uk/338-php-lesson-2/</guid>
		<description><![CDATA[In a previous post I started you off on the basics of PHP and you managed to get Hello World! displayed on the screen. This lesson we are going to learn about how to create, use and manage variables. Hope you enjoy it&#8230; Lesson 2: Variables Unlike programming languages such as C++, in PHP you [...]]]></description>
			<content:encoded><![CDATA[<p><img class="float_l" src='http://blog.eop.org.uk/wp-content/uploads/2007/02/tutorials.jpg' alt='Sunny Man’s Tutorials' />In a <a href="http://blog.eop.org.uk/336-php-lesson-1/">previous post</a> I started you off on the basics of PHP and you managed to get <strong>Hello World!</strong> displayed on the screen. This lesson we are going to learn about how to create, use and manage variables. Hope you enjoy it&#8230;</p>
<h5>Lesson 2: Variables</h5>
<p>Unlike programming languages such as C++, in PHP you don&#8217;t have to state what type of variable you&#8217;re creating when you create one. A variable such as <em>$myvar</em> could just as well be a number as it could be a word. It&#8217;s as easy as pie to create different variables:</p>
<p><code>&lt;?php<br />
$age = 15;<br />
$name = "John";<br />
?&gt;</code></p>
<p>Here we created 2 variables: <em>$age</em> and <em>$name</em> which values&#8217; are 15 and &#8216;John&#8217; respectively. It&#8217;s that easy to create variables. Now that we have created variables we can manipulate them. Say for example we wanted to increase the <em>$age</em> variable and assign the new value to <em>$age</em> again, this is what we would add before the end of the script:</p>
<p><code>$age = $age+1;</code></p>
<p>If we now output the <em>$age</em> variable we would find that it displays <strong>16</strong> and not 15.</p>
<p><code>echo $age; <span style="color:#0cf;">//this would display '15'</span></code></p>
<p>We can also attach strings together. Take the <em>$name</em> variable we created earlier. We can take that and also create a last name in a different variable and then string them together to make the <em>$name</em> variable include the first and last name. Here we go:</p>
<p><code>$lastname = "Smith";<br />
$fullname = $name.$lastname; <span style="color:#0cf;">//this would create "JohnSmith"</span><br />
$fullname = $name." ".$lastname; <span style="color:#0cf;">//this would create "John Smith"</span></code></p>
<p>So, let&#8217;s try and put this all together and make a useful program out of it. Here we manipulate the age by turning it into dog years. We also here string the first and last names together and then as a step towards the next lesson we&#8217;ll count the number of characters in the names.</p>
<p><code>&lt;?php<br />
$age = 15;<br />
$firstname = "John";<br />
$lastname = "Smith";<br />
$i = 0; <span style="color:#0cf;">//used later on as a counter</span><br />
<br />$dog = $age*7;<br />
echo "You're ".$age." human years old and ".$dog." dog years!";<br />
echo "&lt;br /&gt;"; <span style="color:#0cf;">//create a new line; just regular html</span><br />
<br />$name = $firstname." ".$lastname;<br />
$i = $i + strlen($firstname); <span style="color:#0cf;">//0 + 4</span><br />
$i = $i + strlen($lastname); <span style="color:#0cf;">//4 + 5</span><br />
echo $name.", you have ".$i." letters in your name!";<br />
?&gt;</code></p>
<p>Try it out and play around with it! Next lesson we&#8217;re going to look at some of the functions we can apply to strings such as getting the length of the string and searching for a specific item within a variable.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eop.org.uk/338-php-lesson-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Lesson 1</title>
		<link>http://blog.eop.org.uk/336-php-lesson-1/</link>
		<comments>http://blog.eop.org.uk/336-php-lesson-1/#comments</comments>
		<pubDate>Mon, 05 Feb 2007 17:13:18 +0000</pubDate>
		<dc:creator>Sunny Man</dc:creator>
				<category><![CDATA[Educational]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.eop.org.uk/336-php-lesson-1/</guid>
		<description><![CDATA[I&#8217;m going to start producing a few classes for those people who wish to start learning the wonderful programming language of PHP. These will be pretty simple classes and will reach until the end of my knowledge of the language. First, a bit of my experience &#8211; albeit a relatively short one. My History I [...]]]></description>
			<content:encoded><![CDATA[<p><img class="float_l" src='http://blog.eop.org.uk/wp-content/uploads/2007/02/tutorials.jpg' alt='Sunny Man’s Tutorials' />I&#8217;m going to start producing a few classes for those people who wish to start learning the wonderful programming language of <a href="http://www.php.net/">PHP</a>. These will be pretty simple classes and will reach until the end of my knowledge of the language. First, a bit of my experience &#8211; albeit a relatively short one.</p>
<h5>My History</h5>
<p>I first started to learn PHP 3 years ago and have since then done some things I&#8217;m quite proud of in the language. I&#8217;ve built a system for a hospital in Reading, my own blogging software (although quite simple, it does the job) and also a file directory viewer with AJAX technology. But, my PHP knowledge is quite limited and I have not used the language now for some times as I have been concentrating on the design aspect of the web.</p>
<h5>Lesson 1: Hello World!</h5>
<p>Every programmer starts off with the &#8216;Hello World!&#8217; program. Here we are going to get PHP to output the text &#8216;Hello World!&#8217; to the screen. From this point out I&#8217;ll assume you&#8217;ve installed PHP and have it running on <a href="http://www.apache.org/">Apache</a> or the like.</p>
<p>So, as with any PHP script we have to tell the server it&#8217;s going to be dealing with PHP. So we start it off with the opening and closing tags. All code goes between these tags:</p>
<p><code>&#60;?php<br />
?&#62;</code></p>
<p>Now, as I said all PHP code goes in between these tags. So, now we have to make it do what we want it to do. So, in between those tags we know insert this line of code which tells it to output the text to the screen:</p>
<p><code>echo "Hello World!";</code></p>
<p>Once we&#8217;ve put this all together we should be able to achieve the result we wanted. Try it yourself on your own server! Just save the following code as a .php file and run it!</p>
<p><code>&#60;?php<br />
echo "Hello World!";<br />
?&#62;</code></p>
<p>It&#8217;s going to get a bit more complicated than this, I can assure you. I&#8217;ll post a lesson every weekday &#8211; every Friday we&#8217;ll do a roundup of everything we&#8217;ve learnt!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eop.org.uk/336-php-lesson-1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Theme Development Process</title>
		<link>http://blog.eop.org.uk/303-theme-development-process/</link>
		<comments>http://blog.eop.org.uk/303-theme-development-process/#comments</comments>
		<pubDate>Sat, 06 Jan 2007 00:28:30 +0000</pubDate>
		<dc:creator>Sunny Man</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.eop.org.uk/303-theme-development-process/</guid>
		<description><![CDATA[In celebration of my acceptance into the 9rules community I decided, once again, to create another WordPress theme for my blog &#8211; this time with a much more professional look and with a little more beauty under the hood. It has taken me just over 3 days to plan, mock, test and implement the new [...]]]></description>
			<content:encoded><![CDATA[<p><img class="float_l" src="http://blog.eop.org.uk/wp-content/uploads/2007/01/coffee.jpg" alt="Web Design" />In celebration of my acceptance into the <a href="http://www.9rules.com">9rules</a> community I decided, once again, to create another <a href="http://www.wordpress.org">WordPress</a> theme for my blog &#8211; this time with a much more professional look and with a little more beauty under the hood. It has taken me just over 3 days to plan, mock, test and implement the new design and I know that it&#8217;s a good one because I like it and for some reason, I just have to look at it every now and again. While developing it I wondered how other people planned, mocked and tested their designs and whether or not I was doing things correctly. I wondered how the design process worked for professional designers and whether or not I was detailed enough in the three stages. Here I&#8217;m going to document the design and its progress from a few days ago when I started it.</p>
<h5>Planning</h5>
<p>Usually when I&#8217;m planning a design I would start with a piece of paper, a pencil and a rubber. But, I&#8217;ve found that when designing a WordPress theme, I prefer to start in my favourite image editor, Fireworks. I find being able to visualise the layout and make changes at my whim, and on-the-go, makes the process much faster and, apparently much more fun. I start with a blank canvas 1024 pixels wide by 2000 pixels high and I set to work. In the past I&#8217;ve used a colour scheme generator to give me a palette of colours that I can work with but this time I just went in with a choice of all the colours you could wish for. </p>
<p>I chose 3 colours I would make the design around &#8211; light black (#333), white (#fff) and my iconic &#8216;Wii&#8217; blue (#0cf). I then set to work with the ideas in my head. I always seem to prefer to create fixed width layouts possibly because it is a reflection on my personality. I like things to be structured and things to be the same from all angles; by this I mean I like it to look similar on all platforms, in all browsers and all resolutions. I&#8217;ve only ever done a few fluid layouts because of browser CSS support back when IE6 was the latest version of IE but now that IE7 has been released I hope to design a few more, even if just for fun. I&#8217;m digressing here, back to colours. As I said I gave myself a limited palette to work with and the idea of a fixed width design and the inspiration from the world wide web.</p>
<p>I set the background colour of the canvas to my light black and then layed down my content area, defined by a white box. My main points of detail for this design were to reduce the header size, place the search function in the header, advertise my acceptance into 9rules and to sort out display issues with my bookmarks in IE6. As I designed it from the top down I was asking myself <em>is the possible?</em> and if it was I was asking <em>how would I do this?</em> The design for the homepage was complete but I wanted to add another stage to planning as I&#8217;d faced problems in the past when I hadn&#8217;t done it. I previously hadn&#8217;t designed the comments and respond section for any WordPress themes and I always hadn&#8217;t been happy with the final result because I&#8217;d been unprepared.</p>
<p>I&#8217;d finished both plans (<a href="http://blog.eop.org.uk/wp-content/uploads/2007/01/mockup_jpeg.jpg" title="Sunny Man's Blog Homepage Mockup">homepage</a> and <a href="http://blog.eop.org.uk/wp-content/uploads/2007/01/mockup_single.jpg" title="Sunny Man's Blog Post Mockup">single page</a>) now in my image editor, it was late at night and I realised I&#8217;d spent a good five or six hours doing both plans in Fireworks. I wondered whether I was sad or just committed. Next stage is creating a HTML template of the design.</p>
<h5>Mocking Up</h5>
<p>The next stage in my development process was to turn my graphical plans into poetry, or in my case code. I decided to deviate from my usual header, content, footer div code layout but not too far. I start off with a XHTML Transitional template &#8211; because I like to use the strike through tag &#8211; and work from there. I have two Notepad2 windows open: one for the template and one for the cascading style sheet and deviate between the two. I tend to write the template code to the next milestone then turn to the CSS, write that and then view it in my native browser. If anything needs changing I do so. Once I&#8217;ve reached a major milestone such as I&#8217;ve finished the header I will get out my pack of browsers: Opera, Internet Explorer 7, Internet Explorer 6 and of course Firefox. When it&#8217;s not being spammed I&#8217;ll also require the services of <a href="http://danvine.com/">Dan Vine</a>&#8216;s service <a href="http://danvine.com/icapture/">iCapture</a> which will allow me to view it in Safari on a Mac &#8211; a very handy tool for me, a Windows user.</p>
<p>It usually takes me around two days (accounting for procrastination) to finalise the design in HTML, find any rendering errors and sort them out but this time it took less than a day. I actively used the W3C validation tools and although I don&#8217;t actually understand the thinking behind some of it, I use section 508 and WCAG validation tools. Thanks the kindness of a few friends I received some suggestions and opinions on the design. I like to ask a select group of their opinions as they know their stuff and I respect their opinions. I tweaked a couple visual options and then the day was over again. Time to start turning <a href="http://eop.org.uk/stuff/sblog6/3/">the template</a> into a theme.</p>
<h5>Theme Building</h5>
<p>Turning the template into a WordPress theme is the easy part in my opinion. I don&#8217;t like to overcomplicate things and so I only use the minimum of files required to make the theme work. I like the process of cutting up the code and placing the parts into their respective files. As I do so, I keep checking to see how the template integrates with the content over the template-to-theme period.</p>
<p>Because I hadn&#8217;t transformed my plan for the comments into HTML for my template, I had to create this from scratch now. I love turning an image into code and seeing it displayed on the screen &#8211; code is poetry, as WordPress says. When I was doing this I came across a bookmark I had made sometime back that linked to a set of over 1000 free icons made by <a href="http://www.famfamfam.com/">Mark James</a>, called &#8216;<a href="http://www.famfamfam.com/lab/icons/silk/">Silk</a>&#8216;. I decided to try and implement them into my design some how and thought that to fill some space, the comments section would be perfect. I think they work well and go with the overall &#8216;feel&#8217; of the design. The transformation from template to WordPress theme took a day and I have to say I&#8217;m proud. </p>
<h5>Final Theme Thoughts</h5>
<p>This is my sixth design in the Sunny Man&#8217;s/Boy&#8217;s Blog series and I think it&#8217;s my best design yet in terms of aesthetics, accessibility and semantics. I don&#8217;t think I&#8217;ve reached the limit of my talents just yet either. I&#8217;m was so honoured that I was accepted into 9rules, I think it propelled me to just show that they didn&#8217;t make a wrong decision. I&#8217;m not the most precise or concise writer and I tend to deviate from the point I want to make but I hope that some of my points and thoughts get through on the topics I&#8217;m now going to concentrate on.</p>
<p>The new theme I think is very elegant although I&#8217;m not sure whether it is better centred as it is now or aligned to the left, as I planned it. Hopefully people will like it, but it&#8217;s more to please me and to boost my ego I suppose! So, that was the development of this theme from start to finish. Not very detailed, I&#8217;m sorry, but I keep forgetting to take screen shots of the development process and making an animated gif out of them as some in the past have. It&#8217;s 00:27 and <s>Celebrity</s> Big Brother is rather tedious. Goodnight.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eop.org.uk/303-theme-development-process/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>ClickTale</title>
		<link>http://blog.eop.org.uk/283-clicktale/</link>
		<comments>http://blog.eop.org.uk/283-clicktale/#comments</comments>
		<pubDate>Tue, 12 Dec 2006 20:18:04 +0000</pubDate>
		<dc:creator>Sunny Man</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.eop.org.uk/283-clicktale/</guid>
		<description><![CDATA[I&#8217;ve was invited to join the closed beta of the Israeli start up ClickTale. The service allows you to see a snapshot of what your visitors do and it records their mouse movements, actions and text input in real time. I was sceptical at first but although the beta service isn&#8217;t quite what they advertise [...]]]></description>
			<content:encoded><![CDATA[<p><img class="float_l" src="http://blog.eop.org.uk/wp-content/uploads/2006/12/clicktale.jpg" alt="ClickTale" />I&#8217;ve was invited to join the closed beta of the Israeli start up <a href="http://www.clicktale.com/">ClickTale</a>. The service allows you to see a snapshot of what your visitors do and it records their mouse movements, actions and text input in real time. I was sceptical at first but although the beta service isn&#8217;t quite what they advertise on their main site, it has got most of the features and sure is something unique &#8211; and something I think could be very useful. I&#8217;m going to cover what features ClickTale provides, their uses and also the privacy issue that ClickTale brings to the table.</p>
<h5>Mice Behaviour</h5>
<p>There is a lot of statistic services out there that track your visitors, where they come from, where they enter from and how long they stay on your site &#8211; some even go as far as to provide a heat map of &#8216;hot spots&#8217; on your site that are clicked more. But what ClickTale does is unique in that it tracks the mouse movements of the visitor around your site, whether they right or left click and also what text they enter into fields such as searches. It records these movements and allows you to see what the visitor is checking out when and where &#8211; where do they go as soon as the page loads?</p>
<p>This is useful to site owners because in order to optimise your site or service you first need to understand the habits of your users. ClickTale bridges the <img class="float_r" src="http://blog.eop.org.uk/wp-content/uploads/2006/12/clicktale1.jpg" alt="ClickTale - Concept and Beta Differences" />gap between eye tracking and statistics for websites. I&#8217;ve found that when I&#8217;m browsing a website, especially a text heavy site, I follow my mouse with my eyes as a reading aid. Watching how a user navigates around the site, how a user responds to links or images can be vital information for any site owner not only in designing the user interface but other style decisions.</p>
<h5>Data Analysis</h5>
<p>Having all the data being made into the movies of the users&#8217; movements and actions is very nice but what ClickTale also does is provide a statistical analysis of the data it collects. Much like <a href="http://www.google.com/analytics/">Google Analytics</a> (although at time of writing much less advanced) it provides data grouped by country, language, browser, operating system, screen sizes and window sizes. Although the statistical analysis is not as comprehensive as Google Analytics or say <a href="http://awstats.sourceforge.net/">AWStats</a>, I think that the main feature of seeing what your visitors do could potentially be more useful and important. At the moment the analysis is limited to what I&#8217;ve mentioned above but I feel that a lot more could be done with the data.</p>
<p>The data could be transformed into a &#8216;heat map&#8217; of mouse movement and actions &#8211; which parts of the page does the mouse move over most, which links are most clicked and which parts of the page are seen the most. Services such as <a href="http://www.crazyegg.com/">Crazy Egg</a> already offer a service that creates &#8216;heat maps&#8217; based on where users are clicking. This is useful as it shows which links are used the most but tracking mouse movement could potentially be more useful. Mouse movement usually signals interest on the visitor&#8217;s side. In my own experience, if I&#8217;m weary of a link I hover over it first and see what it points to. If I&#8217;m not, I go straight to it. The behaviour of the user&#8217;s cursor can say a lot about how visitors perceive your site and provide suggestions on how you can make the user feel safer browsing your site.</p>
<h5>Privacy Issues</h5>
<p>Obviously, with the fact that visitors&#8217; mouse movements, text input and mouse actions are all recorded, the issue of privacy arises. ClickTale battles <img class="float_l" src="http://blog.eop.org.uk/wp-content/uploads/2006/12/clicktale2.jpg" alt="ClickTale - Browser Statistics" />some of the arguments about privacy by not recording password inputs, not recording any activity outside the web page, not tracking visitors between websites, not tracking any personal files, internet history or interacting with any local files or software. Also, only authorised people (people with the username and password) can actually view the recorded data.</p>
<p>Although the creators have good intentions for their product, it could be used in the wrong manner. Passwords could be captured via a normal text field, some crafty JavaScript and ClickTale. If the users are properly screened though, this could be avoided.</p>
<h5>Final Thoughts</h5>
<p>I love the idea of ClickTale and since trying it out on my own blog, it&#8217;s been interesting to watch the visitors&#8217; movements, where they click, and how much of my posts they really do read! Although it&#8217;s been in closed development and testing since the early part of this year, it seems the wait will be worth it. In my case as a small blog owner, it has been interesting to see how the users interact with my bookmarks, seeing whether or not that use the lower part of the sidebar and also seeing whether or not they find searching intuitive.</p>
<p>Also, the fact that adding the service to your site is done by just two pieces of JavaScript means that site operators will find it incredibly easy to use. Once the user interface has been polished, I think that it would be a vital service for any serious website owner.</p>
<p><strong>Oh, and a special thanks to Arik for giving me permission to write this review and including shots of the current user interface.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eop.org.uk/283-clicktale/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Messenger Plus! Live Script</title>
		<link>http://blog.eop.org.uk/279-messenger-plus-live-script/</link>
		<comments>http://blog.eop.org.uk/279-messenger-plus-live-script/#comments</comments>
		<pubDate>Sun, 03 Dec 2006 09:34:49 +0000</pubDate>
		<dc:creator>Sunny Man</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.eop.org.uk/279-messenger-plus-live-script/</guid>
		<description><![CDATA[I&#8217;m just posting a little advertisement really to let you all know about a script I wrote for Messenger Plus! Live. It&#8217;s my first piece of JavaScript that doesn&#8217;t use alert() so I&#8217;m pretty proud of it. It&#8217;s not much but I&#8217;m pretty proud of it to be honest. It&#8217;s a simple and quick alarm/reminder [...]]]></description>
			<content:encoded><![CDATA[<p><img class="float_l" src="http://blog.eop.org.uk/wp-content/uploads/2006/12/msgpluslive_dp1.png" alt="Messenger Plus! Live" />I&#8217;m just posting a little advertisement really to let you all know about a script I wrote for <a href="http://www.msgpluslive.net/">Messenger Plus! Live</a>. It&#8217;s my first piece of JavaScript that doesn&#8217;t use alert() so I&#8217;m pretty proud of it. It&#8217;s not much but I&#8217;m pretty proud of it to be honest. </p>
<p>It&#8217;s a simple and quick alarm/reminder script that is used by typing <em>/reminder &lt;minutes&gt;</em> in any conversation window. That&#8217;s all it is. It displays a notice when the time is up and also if your settings allow it, a pretty annoying sound is played (the phone sound distributed with Messenger). Hopefully in version 2.0 I&#8217;ll be adding custom reminder messages but I gotta learn that first!</p>
<p><a href="http://www.msgpluslive.net/scripts/view/168-Quick-Alarm/Reminder-Script/">http://www.msgpluslive.net/scripts/view/168-Quick-Alarm/Reminder-Script/</a></p>
<p><strong>Sorry but this week&#8217;s News Roundup/Where&#8217;s Herbert?/Cluedo will be postponed a week. Had a lot of other things to do besides that like reminder script 2.0 and school work.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eop.org.uk/279-messenger-plus-live-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extraordinary Paraphernalia Update</title>
		<link>http://blog.eop.org.uk/225-extraordinary-paraphernalia-update/</link>
		<comments>http://blog.eop.org.uk/225-extraordinary-paraphernalia-update/#comments</comments>
		<pubDate>Mon, 23 Oct 2006 21:37:02 +0000</pubDate>
		<dc:creator>Sunny Man</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.eop.org.uk/225-extraordinary-paraphernalia-update/</guid>
		<description><![CDATA[Just though that I&#8217;d make a note that the main Extraordinary Paraphernalia page has been updates with a new design and layout to advertise a new service. I don&#8217;t expect anyone to actually use it, but I&#8217;ve just done some editing of WordPress MU to morph it into Sunny Man&#8217;s Community. Create an account, take [...]]]></description>
			<content:encoded><![CDATA[<p><img class="float_l" src="http://blog.eop.org.uk/wp-content/uploads/2006/10/note.jpg" alt="A note from Sunny" />Just though that I&#8217;d make a note that the main <a href="http://www.eop.org.uk" title="Extraordinary Paraphernalia">Extraordinary Paraphernalia</a> page has been updates with a new design and layout to advertise a new service. I don&#8217;t expect anyone to actually use it, but I&#8217;ve just done some editing of <a href="http://mu.wordpress.org/">WordPress MU</a> to morph it into <a href="http://my.eop.org.uk">Sunny Man&#8217;s Community</a>. Create an account, take a look even if you&#8217;re not going to use it in the future.</p>
<p>Oh, and I&#8217;ve won a 30GB Video iPod courtesy of <a href="http://www.derby.ac.uk/">Derby University</a>. Check out their site and watch out for the television add that has been on your screen for a few weeks! Wow. Apparantly I&#8217;m going to be featured on their website and in their internal publication! Many thanks to them.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eop.org.uk/225-extraordinary-paraphernalia-update/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

