<?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>MaggsWeb:7 &#187; PHP</title>
	<atom:link href="http://www.maggsweb.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maggsweb.com</link>
	<description>www.maggsweb.com</description>
	<lastBuildDate>Sat, 21 Aug 2010 20:50:00 +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>Send email with attachments class</title>
		<link>http://www.maggsweb.com/php/send-email-with-attachments-class/</link>
		<comments>http://www.maggsweb.com/php/send-email-with-attachments-class/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 11:01:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[attachment]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[mail]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=1006</guid>
		<description><![CDATA[Very similar to the previous post on the same subject, but this time put into a &#8216;class&#8217; file for neatness.. I have just used this on the new www.lady-drivers.co.uk site for sending Vouchers by email after subscribing. ?View Code PHP&#60;?php &#160; &#160; // USAGE // $mailer = new AttachMailer(&#34;emailer@maggsweb.com&#34;, &#34;you@yourdomain.com&#34;, &#34;Email Sender&#34;, &#34;hello &#60;b&#62;content&#60;/b&#62;&#34;); // [...]]]></description>
			<content:encoded><![CDATA[<p>Very similar to the previous post on the same subject, but this time put into a &#8216;class&#8217; file for neatness..<br />
I have just used this on the new <a href="http://www.lady-drivers.co.uk/Vouchers/" onclick="pageTracker._trackPageview('/outgoing/www.lady-drivers.co.uk/Vouchers/?referer=');">www.lady-drivers.co.uk</a> site for sending Vouchers by email after subscribing.</p>
<p><span id="more-1006"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1006code2'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10062"><td class="code" id="p1006code2"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">// USAGE</span>
<span style="color: #666666; font-style: italic;">// $mailer = new AttachMailer(&quot;emailer@maggsweb.com&quot;, &quot;you@yourdomain.com&quot;, &quot;Email Sender&quot;, &quot;hello &lt;b&gt;content&lt;/b&gt;&quot;);</span>
<span style="color: #666666; font-style: italic;">// $mailer-&gt;attachFile(&quot;a.pdf&quot;);</span>
<span style="color: #666666; font-style: italic;">// $mailer-&gt;attachFile(&quot;b.pdf&quot;);</span>
<span style="color: #666666; font-style: italic;">// $mailer-&gt;send() ? &quot;Success&quot;: &quot;Ooops, an Error occurred!&quot;;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * send emails with pdf attachment
 */</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> AttachMailer<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$from</span><span style="color: #339933;">,</span> <span style="color: #000088;">$to</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mess</span><span style="color: #339933;">,</span> <span style="color: #000088;">$hash</span><span style="color: #339933;">,</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$documents</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array" onclick="pageTracker._trackPageview('/outgoing/www.php.net/array?referer=');"><span style="color: #990000;">Array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/*
	 * @params from: sender (email format)
	 * 		   to : recipient (email format)
	 * 		   subject : Subject line
	 * 		   mess : HTML formatted message
	 */</span>
	<span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_from</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_to</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_subject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_mess</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_from</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">to</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_to</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">subject</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_subject</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mess</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_mess</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hash</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/md5" onclick="pageTracker._trackPageview('/outgoing/www.php.net/md5?referer=');"><span style="color: #990000;">md5</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'r'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/time" onclick="pageTracker._trackPageview('/outgoing/www.php.net/time?referer=');"><span style="color: #990000;">time</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/*
	 * @params url : document path
	 */</span>	
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> attachFile<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$attachment</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/chunk_split" onclick="pageTracker._trackPageview('/outgoing/www.php.net/chunk_split?referer=');"><span style="color: #990000;">chunk_split</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/base64_encode" onclick="pageTracker._trackPageview('/outgoing/www.php.net/base64_encode?referer=');"><span style="color: #990000;">base64_encode</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_get_contents" onclick="pageTracker._trackPageview('/outgoing/www.php.net/file_get_contents?referer=');"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$docName</span>    <span style="color: #339933;">=</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;&quot;</span> ? <a href="http://www.php.net/basename" onclick="pageTracker._trackPageview('/outgoing/www.php.net/basename?referer=');"><span style="color: #990000;">basename</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$name</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$randomHash</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hash</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$docOutput</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;--PHP-alt-<span style="color: #006699; font-weight: bold;">$randomHash</span>--<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
					 <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;--PHP-mixed-<span style="color: #006699; font-weight: bold;">$randomHash</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
					 <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;Content-Type: application/pdf; name=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$docName</span><span style="color: #000099; font-weight: bold;">\&quot;</span> <span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
					 <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;Content-Transfer-Encoding: base64 <span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
					 <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;Content-Disposition: attachment <span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
					 <span style="color: #339933;">.</span><span style="color: #000088;">$attachment</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">documents</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$docOutput</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> makeMessage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$randomHash</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hash</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$messageOutput</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;--PHP-mixed-<span style="color: #006699; font-weight: bold;">$randomHash</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
						 <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;Content-Type: multipart/alternative; boundary=PHP-alt-<span style="color: #006699; font-weight: bold;">$randomHash</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
						 <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;--PHP-alt-<span style="color: #006699; font-weight: bold;">$randomHash</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
						 <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;Content-Type: text/plain; charset='iso-8859-1'<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
						 <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;Content-Transfer-Encoding: 7bit<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
						 <span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mess</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
						 <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;--PHP-alt-<span style="color: #006699; font-weight: bold;">$randomHash</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
						 <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;Content-Type: text/html; charset='iso-8859-1'<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
						 <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;Content-Transfer-Encoding: 7bit<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
						 <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mess</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">documents</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$document</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$messageOutput</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$document</span><span style="color: #339933;">;</span> 
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$messageOutput</span> <span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot;--PHP-mixed-<span style="color: #006699; font-weight: bold;">$randomHash</span>;--&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$messageOutput</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> send<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">makeMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$from</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$randomHash</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hash</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$headers</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;From: <span style="color: #006699; font-weight: bold;">$from</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>Reply-To: <span style="color: #006699; font-weight: bold;">$from</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$headers</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>Content-Type: multipart/mixed; boundary=<span style="color: #000099; font-weight: bold;">\&quot;</span>PHP-mixed-<span style="color: #006699; font-weight: bold;">$randomHash</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$mail_sent</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><a href="http://www.php.net/mail" onclick="pageTracker._trackPageview('/outgoing/www.php.net/mail?referer=');"><span style="color: #990000;">mail</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">to</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">subject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #339933;">,</span> <span style="color: #000088;">$headers</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$mail_sent</span> ? <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/send-email-with-attachments-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code commenting with Doc Blocks</title>
		<link>http://www.maggsweb.com/php/code-commenting-doc-blocks/</link>
		<comments>http://www.maggsweb.com/php/code-commenting-doc-blocks/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 08:41:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[commenting]]></category>
		<category><![CDATA[doc-block]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=985</guid>
		<description><![CDATA[Code commenting can be a pain. If its your code then you know exactly what it does and why. If its someone else&#8217;s code &#8211; then all of a sudden they are invaluable. The Doc Block commenting style is a widely used standard for commenting accross all languages, and can also be used to generate [...]]]></description>
			<content:encoded><![CDATA[<p>Code commenting can be a pain.  If its your code then you know exactly what it does and why.  If its someone else&#8217;s code &#8211; then all of a sudden they are invaluable.  The Doc Block commenting style is a widely used standard for commenting accross all languages, and can also be used to generate code hints and automatic documentation if used properly. </p>
<p>The following guide to code-commenting is taken from: <a href="http://net.tutsplus.com/tutorials/php/object-oriented-php-for-beginners/" target="_new" onclick="pageTracker._trackPageview('/outgoing/net.tutsplus.com/tutorials/php/object-oriented-php-for-beginners/?referer=');">http://net.tutsplus.com/tutorials/php/object-oriented-php-for-beginners/</a></p>
<p><span id="more-985"></span></p>
<p>The real power of DocBlocks comes with the ability to use tags, which start with an at symbol (@) immediately followed by the tag name and the value of the tag. DocBlock tags allow developers to define authors of a file, the license for a class, the property or method information, and other useful information.</p>
<p>The most common tags used:</p>
<p>@author: The author of the current element (which might be a class, file, method, or any bit of code) are listed using this tag. Multiple author tags can be used in the same DocBlock if more than one author is credited. The format for the author name is John Doe .<br />
@copyright: This signifies the copyright year and name of the copyright holder for the current element. The format is 2010 Copyright Holder.<br />
@license: This links to the license for the current element. The format for the license information is<br />
http://www.example.com/path/to/license.txt License Name.<br />
@var: This holds the type and description of a variable or class property. The format is type element description.<br />
@param: This tag shows the type and description of a function or method parameter. The format is type $element_name element description.<br />
@return: The type and description of the return value of a function or method are provided in this tag. The format is type return element description.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p985code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9854"><td class="code" id="p985code4"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/** 
 * A simple class 
 * 
 * This is the long description for this class, 
 * which can span as many lines as needed. It is 
 * not required, whereas the short description is 
 * necessary. 
 * 
 * It can also span multiple paragraphs if the 
 * description merits that much verbiage. 
 * 
 * @author Jason Lengstorf &lt;jason.lengstorf@ennuidesign.com&gt; 
 * @copyright 2010 Some Design Company
 * @license http://www.php.net/license/3_01.txt PHP License 3.01
 */</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> SimpleClass
<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
     * A public variable
     *
     * @var string stores data for the class
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$foo</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Sets $foo to a new value upon class instantiation
     *
     * @param string $val a value required for the class
     * @return void
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>foo <span style="color: #339933;">=</span> <span style="color: #000088;">$val</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Multiplies two integers
     *
     * Accepts a pair of integers and returns the
     * product of the two.
     *
     * @param int $bat a number to be multiplied
     * @param int $baz a number to be multiplied
     * @return int the product of the two parameters
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> bar<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bat</span><span style="color: #339933;">,</span> <span style="color: #000088;">$baz</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$bat</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$baz</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/code-commenting-doc-blocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compressing CSS files &#8211; on the fly</title>
		<link>http://www.maggsweb.com/php/compressing-files-on-the-fly/</link>
		<comments>http://www.maggsweb.com/php/compressing-files-on-the-fly/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 07:30:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[compress]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=978</guid>
		<description><![CDATA[I hate compressing CSS files as they become totally unreadable for editing. I end up keeping 2 versions, compressed and uncompressed, etc.. But how about compressing all your CSS files into one file, &#8216;on-the-fly&#8217;. Now that has solved the problem. ?View Code PHP&#60;?php &#160; header&#40;'Content-type: text/css'&#41;; &#160; ob_start&#40;&#34;compress&#34;&#41;; &#160; function compress&#40;$buffer&#41; &#123; /* remove comments [...]]]></description>
			<content:encoded><![CDATA[<p>I hate compressing CSS files as they become totally unreadable for editing.  I end up keeping 2 versions, compressed and uncompressed, etc..   But how about compressing all your CSS files into one file, &#8216;on-the-fly&#8217;.  Now that has solved the problem.</p>
<p><span id="more-978"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p978code7'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9787"><td class="code" id="p978code7"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<a href="http://www.php.net/header" onclick="pageTracker._trackPageview('/outgoing/www.php.net/header?referer=');"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-type: text/css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<a href="http://www.php.net/ob_start" onclick="pageTracker._trackPageview('/outgoing/www.php.net/ob_start?referer=');"><span style="color: #990000;">ob_start</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;compress&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> compress<span style="color: #009900;">&#40;</span><span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">/* remove comments */</span>
  <span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/preg_replace?referer=');"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!/\*[^*]*\*+([^/][^*]*\*+)*/!'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">/* remove tabs, spaces, newlines, etc. */</span>
  <span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/str_replace?referer=');"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array" onclick="pageTracker._trackPageview('/outgoing/www.php.net/array?referer=');"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'  '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'    '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'    '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$buffer</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* your css files */</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'master.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'typography.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'grid.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'print.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'handheld.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<a href="http://www.php.net/ob_end_flush" onclick="pageTracker._trackPageview('/outgoing/www.php.net/ob_end_flush?referer=');"><span style="color: #990000;">ob_end_flush</span></a><span style="color: #009900;">&#40;</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>Use it like this :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p978code8'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9788"><td class="code" id="p978code8"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; href=&quot;style.php&quot; type=&quot;text/css&quot; media=&quot;all&quot;&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/compressing-files-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First date of the week</title>
		<link>http://www.maggsweb.com/php/first-date-of-the-week/</link>
		<comments>http://www.maggsweb.com/php/first-date-of-the-week/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 10:06:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=965</guid>
		<description><![CDATA[Just a little script I wrote to work out the date of the first day of the week. ?View Code PHP&#60;?php &#160; $yearNow = date&#40;'Y', $time&#41;; $monthNow = date&#40;'m', $time&#41;; $dayNow = date&#40;'d', $time&#41;; &#160; $first_day_of_week = 'Mon'; // Sat &#124; Sun &#124; Mon &#124; etc.. $day = $dayNow; // dont overwrite $dayNow! &#160; while [...]]]></description>
			<content:encoded><![CDATA[<p>Just a little script I wrote to work out the date of the first day of the week.<br />
<span id="more-965"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p965code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p96510"><td class="code" id="p965code10"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$yearNow</span>  <span style="color: #339933;">=</span> <a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$monthNow</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dayNow</span>   <span style="color: #339933;">=</span> <a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$first_day_of_week</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Mon'</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Sat | Sun | Mon | etc..  </span>
<span style="color: #000088;">$day</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dayNow</span><span style="color: #339933;">;</span>               <span style="color: #666666; font-style: italic;">// dont overwrite $dayNow!</span>
&nbsp;
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$weekday</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$first_day_of_week</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000088;">$weekday</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'D'</span><span style="color: #339933;">,</span><a href="http://www.php.net/mktime" onclick="pageTracker._trackPageview('/outgoing/www.php.net/mktime?referer=');"><span style="color: #990000;">mktime</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$monthNow</span><span style="color: #339933;">,</span><span style="color: #000088;">$day</span><span style="color: #339933;">,</span><span style="color: #000088;">$yearNow</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$weekday</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$first_day_of_week</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         <span style="color: #000088;">$first_date_of_week</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$day</span><span style="color: #339933;">;</span>
         <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span> 
     <span style="color: #000088;">$day</span><span style="color: #339933;">--;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;h2&gt;First date of week is &quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d'</span><span style="color: #339933;">,</span><a href="http://www.php.net/mktime" onclick="pageTracker._trackPageview('/outgoing/www.php.net/mktime?referer=');"><span style="color: #990000;">mktime</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$monthNow</span><span style="color: #339933;">,</span><span style="color: #000088;">$day</span><span style="color: #339933;">,</span><span style="color: #000088;">$yearNow</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/h2&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><em></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/first-date-of-the-week/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Sessions&#8230;</title>
		<link>http://www.maggsweb.com/php/php-sessions/</link>
		<comments>http://www.maggsweb.com/php/php-sessions/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 07:38:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=915</guid>
		<description><![CDATA[Using $_SESSIONS&#8230; Forgot the syntax&#8230; Here-ya-go. Initialize Session This must be at the top of every page that will call/use a Session variable. php session_start(); Register (declare) a Session variable To add a Session variable that will be carried till the browser is closed or you kill it yourself. session_register(&#8220;mySessionVariable&#8221;); Assigning value to a Session [...]]]></description>
			<content:encoded><![CDATA[<p>Using $_SESSIONS&#8230;  Forgot the syntax&#8230;   Here-ya-go.<br />
<span id="more-915"></span><br />
<strong>Initialize Session</strong><br />
This must be at the top of every page that will call/use a Session variable.<br />
php session_start();</p>
<p><strong>Register (declare) a Session variable</strong><br />
To add a Session variable that will be carried till the browser is closed or you kill it yourself.<br />
session_register(&#8220;mySessionVariable&#8221;);</p>
<p><strong>Assigning value to a Session variable</strong><br />
Values added to a Session variable can be letters (ABCabc), numbers (1, 200, 999.99, etc.) making them good for usernames/userID&#8217;s when logged into a site.<br />
$_SESSION["mySessionVariable"] = &#8220;MEMBER&#8221;;</p>
<p><strong>Unregister a Session variable</strong><br />
Logging out requires we unregister any and all Session variables used for our application and the users&#8217; account.<br />
session_unregister(&#8220;mySessionVariable&#8221;);</p>
<p><strong>Destroy a Session</strong><br />
We should always destroy a Session to help complete a logout.<br />
session_destroy();</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/php-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a &#8216;slug&#8217;</title>
		<link>http://www.maggsweb.com/php/creating-a-slug/</link>
		<comments>http://www.maggsweb.com/php/creating-a-slug/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 07:34:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[slug]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=917</guid>
		<description><![CDATA[SEO is becoming more and more important, and URL&#8217;s need to be more visible. Here&#8217;s a function for creating a &#8216;slug&#8217; which I used as an add-on to a site, using the page title. ?View Code PHP&#60;?php function slug&#40;$str&#41;&#123; $str = strtolower&#40;trim&#40;$str&#41;&#41;; $str = preg_replace&#40;'/[^a-z0-9-]/', '-', $str&#41;; $str = preg_replace&#40;'/-+/', &#34;-&#34;, $str&#41;; return $str; &#125; [...]]]></description>
			<content:encoded><![CDATA[<p>SEO is becoming more and more important, and URL&#8217;s need to be more visible.  Here&#8217;s a function for creating a &#8216;slug&#8217; which I used as an add-on to a site, using the page title.<br />
<span id="more-917"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p917code12'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p91712"><td class="code" id="p917code12"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> slug<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strtolower" onclick="pageTracker._trackPageview('/outgoing/www.php.net/strtolower?referer=');"><span style="color: #990000;">strtolower</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/trim" onclick="pageTracker._trackPageview('/outgoing/www.php.net/trim?referer=');"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/preg_replace?referer=');"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/[^a-z0-9-]/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/preg_replace?referer=');"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/-+/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$str</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/creating-a-slug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MIME Types</title>
		<link>http://www.maggsweb.com/php/mime-types/</link>
		<comments>http://www.maggsweb.com/php/mime-types/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 13:13:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[mime_type]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=823</guid>
		<description><![CDATA[A full(-ish) list of MIME Types that may come in usefull for upload validatiuon. $mimes = array( &#8216;jpg&#124;jpeg&#124;jpe&#8217; => &#8216;image/jpeg&#8217;, &#8216;gif&#8217; => &#8216;image/gif&#8217;, &#8216;png&#8217; => &#8216;image/png&#8217;, &#8216;bmp&#8217; => &#8216;image/bmp&#8217;, &#8216;tif&#124;tiff&#8217; => &#8216;image/tiff&#8217;, &#8216;ico&#8217; => &#8216;image/x-icon&#8217;, &#8216;asf&#124;asx&#124;wax&#124;wmv&#124;wmx&#8217; => &#8216;video/asf&#8217;, &#8216;avi&#8217; => &#8216;video/avi&#8217;, &#8216;divx&#8217; => &#8216;video/divx&#8217;, &#8216;mov&#124;qt&#8217; => &#8216;video/quicktime&#8217;, &#8216;mpeg&#124;mpg&#124;mpe&#8217; => &#8216;video/mpeg&#8217;, &#8216;txt&#124;c&#124;cc&#124;h&#8217; => &#8216;text/plain&#8217;, &#8216;rtx&#8217; => [...]]]></description>
			<content:encoded><![CDATA[<p>A full(-ish) list of MIME Types that may come in usefull for upload validatiuon.<br />
<span id="more-823"></span><br />
$mimes = array(<br />
		&#8216;jpg|jpeg|jpe&#8217; => &#8216;image/jpeg&#8217;,<br />
		&#8216;gif&#8217; => &#8216;image/gif&#8217;,<br />
		&#8216;png&#8217; => &#8216;image/png&#8217;,<br />
		&#8216;bmp&#8217; => &#8216;image/bmp&#8217;,<br />
		&#8216;tif|tiff&#8217; => &#8216;image/tiff&#8217;,<br />
		&#8216;ico&#8217; => &#8216;image/x-icon&#8217;,<br />
		&#8216;asf|asx|wax|wmv|wmx&#8217; => &#8216;video/asf&#8217;,<br />
		&#8216;avi&#8217; => &#8216;video/avi&#8217;,<br />
		&#8216;divx&#8217; => &#8216;video/divx&#8217;,<br />
		&#8216;mov|qt&#8217; => &#8216;video/quicktime&#8217;,<br />
		&#8216;mpeg|mpg|mpe&#8217; => &#8216;video/mpeg&#8217;,<br />
		&#8216;txt|c|cc|h&#8217; => &#8216;text/plain&#8217;,<br />
		&#8216;rtx&#8217; => &#8216;text/richtext&#8217;,<br />
		&#8216;css&#8217; => &#8216;text/css&#8217;,<br />
		&#8216;htm|html&#8217; => &#8216;text/html&#8217;,<br />
		&#8216;mp3|m4a&#8217; => &#8216;audio/mpeg&#8217;,<br />
		&#8216;mp4|m4v&#8217; => &#8216;video/mp4&#8242;,<br />
		&#8216;ra|ram&#8217; => &#8216;audio/x-realaudio&#8217;,<br />
		&#8216;wav&#8217; => &#8216;audio/wav&#8217;,<br />
		&#8216;ogg&#8217; => &#8216;audio/ogg&#8217;,<br />
		&#8216;mid|midi&#8217; => &#8216;audio/midi&#8217;,<br />
		&#8216;wma&#8217; => &#8216;audio/wma&#8217;,<br />
		&#8216;rtf&#8217; => &#8216;application/rtf&#8217;,<br />
		&#8216;js&#8217; => &#8216;application/javascript&#8217;,<br />
		&#8216;pdf&#8217; => &#8216;application/pdf&#8217;,<br />
		&#8216;doc|docx&#8217; => &#8216;application/msword&#8217;,<br />
		&#8216;pot|pps|ppt|pptx&#8217; => &#8216;application/vnd.ms-powerpoint&#8217;,<br />
		&#8216;wri&#8217; => &#8216;application/vnd.ms-write&#8217;,<br />
		&#8216;xla|xls|xlsx|xlt|xlw&#8217; => &#8216;application/vnd.ms-excel&#8217;,<br />
		&#8216;mdb&#8217; => &#8216;application/vnd.ms-access&#8217;,<br />
		&#8216;mpp&#8217; => &#8216;application/vnd.ms-project&#8217;,<br />
		&#8216;swf&#8217; => &#8216;application/x-shockwave-flash&#8217;,<br />
		&#8216;class&#8217; => &#8216;application/java&#8217;,<br />
		&#8216;tar&#8217; => &#8216;application/x-tar&#8217;,<br />
		&#8216;zip&#8217; => &#8216;application/zip&#8217;,<br />
		&#8216;gz|gzip&#8217; => &#8216;application/x-gzip&#8217;,<br />
		&#8216;exe&#8217; => &#8216;application/x-msdownload&#8217;,<br />
		// openoffice formats<br />
		&#8216;odt&#8217; => &#8216;application/vnd.oasis.opendocument.text&#8217;,<br />
		&#8216;odp&#8217; => &#8216;application/vnd.oasis.opendocument.presentation&#8217;,<br />
		&#8216;ods&#8217; => &#8216;application/vnd.oasis.opendocument.spreadsheet&#8217;,<br />
		&#8216;odg&#8217; => &#8216;application/vnd.oasis.opendocument.graphics&#8217;,<br />
		&#8216;odc&#8217; => &#8216;application/vnd.oasis.opendocument.chart&#8217;,<br />
		&#8216;odb&#8217; => &#8216;application/vnd.oasis.opendocument.database&#8217;,<br />
		&#8216;odf&#8217; => &#8216;application/vnd.oasis.opendocument.formula&#8217;<br />
)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/mime-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Manually setting register_globals</title>
		<link>http://www.maggsweb.com/php/manually-register-globals/</link>
		<comments>http://www.maggsweb.com/php/manually-register-globals/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 13:10:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[register_global]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=835</guid>
		<description><![CDATA[This value is generally set in the httpd.conf (server) file, which is generally not accessible to users on shared hosting packages. So, here are a few ways to get around this. In a &#8216;.htaccess&#8217; file, stored in web root: php_value register_globals on or in a &#8216;php.ini&#8217; file, also stored in the web root: register_globals = [...]]]></description>
			<content:encoded><![CDATA[<p>This value is generally set in the httpd.conf (server) file, which is generally not accessible to users on shared hosting packages.  So, here are a few ways to get around this.<br />
<span id="more-835"></span></p>
<p>In a &#8216;.htaccess&#8217; file, stored in web root:<br />
php_value register_globals on</p>
<p>or in a &#8216;php.ini&#8217; file, also stored in the web root:<br />
register_globals = on</p>
<p>More details on this and other override settings can be found in this excellent article: <a href='http://www.sitepoint.com/blogs/2010/03/04/how-to-override-php-configuration-settings/' target='_new' onclick="pageTracker._trackPageview('/outgoing/www.sitepoint.com/blogs/2010/03/04/how-to-override-php-configuration-settings/?referer=');">http://www.sitepoint.com/blogs/2010/03/04/how-to-override-php-configuration-settings/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/manually-register-globals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending email attachments</title>
		<link>http://www.maggsweb.com/php/sending-email-attachments/</link>
		<comments>http://www.maggsweb.com/php/sending-email-attachments/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 18:40:38 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[attachment]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[mail]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=746</guid>
		<description><![CDATA[An example of how to send Text &#038; HTML email with an attachment. ?View Code PHP&#160; &#60;?php &#160; //define the receiver of the email $to = 'youraddress@example.com'; &#160; //define the subject of the email $subject = 'Test email with attachment'; &#160; //create a boundary string. It must be unique //so we use the MD5 algorithm [...]]]></description>
			<content:encoded><![CDATA[<p>An example of how to send Text &#038; HTML email with an attachment.<br />
<span id="more-746"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p746code14'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p74614"><td class="code" id="p746code14"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//define the receiver of the email </span>
<span style="color: #000088;">$to</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'youraddress@example.com'</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">//define the subject of the email </span>
<span style="color: #000088;">$subject</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Test email with attachment'</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">//create a boundary string. It must be unique </span>
<span style="color: #666666; font-style: italic;">//so we use the MD5 algorithm to generate a random hash </span>
<span style="color: #000088;">$random_hash</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/md5" onclick="pageTracker._trackPageview('/outgoing/www.php.net/md5?referer=');"><span style="color: #990000;">md5</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/date" onclick="pageTracker._trackPageview('/outgoing/www.php.net/date?referer=');"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'r'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/time" onclick="pageTracker._trackPageview('/outgoing/www.php.net/time?referer=');"><span style="color: #990000;">time</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">//define the headers we want passed. Note that they are separated with \r\n </span>
<span style="color: #000088;">$headers</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;From: webmaster@example.com<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>Reply-To: webmaster@example.com&quot;</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;">//add boundary string and mime type specification </span>
&nbsp;
<span style="color: #000088;">$headers</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>Content-Type: multipart/mixed; boundary=<span style="color: #000099; font-weight: bold;">\&quot;</span>PHP-mixed-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$random_hash</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">//read the atachment file contents into a string,</span>
<span style="color: #666666; font-style: italic;">//encode it with MIME base64,</span>
<span style="color: #666666; font-style: italic;">//and split it into smaller chunks</span>
<span style="color: #000088;">$attachment</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/chunk_split" onclick="pageTracker._trackPageview('/outgoing/www.php.net/chunk_split?referer=');"><span style="color: #990000;">chunk_split</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/base64_encode" onclick="pageTracker._trackPageview('/outgoing/www.php.net/base64_encode?referer=');"><span style="color: #990000;">base64_encode</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_get_contents" onclick="pageTracker._trackPageview('/outgoing/www.php.net/file_get_contents?referer=');"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'attachment.zip'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">//define the body of the message. </span>
&nbsp;
<a href="http://www.php.net/ob_start" onclick="pageTracker._trackPageview('/outgoing/www.php.net/ob_start?referer=');"><span style="color: #990000;">ob_start</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Turn on output buffering </span>
<span style="color: #000000; font-weight: bold;">?&gt;</span> 
--PHP-mixed-<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$random_hash</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  
Content-Type: multipart/alternative; boundary=&quot;PHP-alt-<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$random_hash</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; 
&nbsp;
--PHP-alt-<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$random_hash</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  
Content-Type: text/plain; charset=&quot;iso-8859-1&quot; 
Content-Transfer-Encoding: 7bit
&nbsp;
Hello World!!! 
This is simple text email message. 
&nbsp;
--PHP-alt-<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$random_hash</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  
Content-Type: text/html; charset=&quot;iso-8859-1&quot; 
Content-Transfer-Encoding: 7bit
&nbsp;
&lt;h2&gt;Hello World!&lt;/h2&gt; 
&lt;p&gt;This is something with &lt;b&gt;HTML&lt;/b&gt; formatting.&lt;/p&gt; 
&nbsp;
--PHP-alt-<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$random_hash</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>-- 
&nbsp;
--PHP-mixed-<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$random_hash</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  
Content-Type: application/zip; name=&quot;attachment.zip&quot;  
Content-Transfer-Encoding: base64  
Content-Disposition: attachment  
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$attachment</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> 
--PHP-mixed-<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$random_hash</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>-- 
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #666666; font-style: italic;">//copy current buffer contents into $message variable and delete current output buffer </span>
<span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ob_get_clean" onclick="pageTracker._trackPageview('/outgoing/www.php.net/ob_get_clean?referer=');"><span style="color: #990000;">ob_get_clean</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;">//send the email </span>
<span style="color: #000088;">$mail_sent</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><a href="http://www.php.net/mail" onclick="pageTracker._trackPageview('/outgoing/www.php.net/mail?referer=');"><span style="color: #990000;">mail</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$to</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$message</span><span style="color: #339933;">,</span> <span style="color: #000088;">$headers</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;">//if the message is sent successfully print &quot;Mail sent&quot;. Otherwise print &quot;Mail failed&quot; </span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$mail_sent</span> ? <span style="color: #0000ff;">&quot;Mail sent&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;Mail failed&quot;</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/sending-email-attachments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>English Ordinals for dates in PHP</title>
		<link>http://www.maggsweb.com/php/english_ordinals_for_dates/</link>
		<comments>http://www.maggsweb.com/php/english_ordinals_for_dates/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 08:07:20 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.maggsweb.com/?p=396</guid>
		<description><![CDATA[Displaying the day-part of the date, followed by the month etc. just looks plain wrong and lazy &#8211; &#8217;20 September 2009&#8242;. &#8217;20th&#8217; would look much nicer and can be achieved without too much hard work. A simple function&#8230; ?View Code PHP&#160; &#60;?php function dispDay&#40;$i&#41; &#123; switch&#40; floor&#40;$i/10&#41; % 10 &#41; &#123; default: switch&#40; $i % [...]]]></description>
			<content:encoded><![CDATA[<p>Displaying the day-part of the date, followed by the month etc. just looks plain wrong and lazy &#8211; &#8217;20 September 2009&#8242;.   &#8217;20th&#8217; would look much nicer and can be achieved without too much hard work.  A simple function&#8230;<br />
<span id="more-396"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p396code16'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p39616"><td class="code" id="p396code16"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #000000; font-weight: bold;">function</span> dispDay<span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span> <a href="http://www.php.net/floor" onclick="pageTracker._trackPageview('/outgoing/www.php.net/floor?referer=');"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">10</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
                <span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">10</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span> <span style="color: #000088;">$ordinal</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'st'</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">:</span> <span style="color: #000088;">$ordinal</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'nd'</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">:</span> <span style="color: #000088;">$ordinal</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'rd'</span><span style="color: #339933;">;</span>   
                <span style="color: #009900;">&#125;</span>
            <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span> <span style="color: #000088;">$ordinal</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'th'</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;sup&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$ordinal</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/sup&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/english_ordinals_for_dates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
