<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>AaronHardy.com &#187; PHP</title>
	<atom:link href="http://aaronhardy.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://aaronhardy.com</link>
	<description>For all your Aaron Hardy needs.</description>
	<lastBuildDate>Thu, 12 Jan 2012 17:51:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Hosting Your Own Free Sexy Photo Gallery</title>
		<link>http://aaronhardy.com/php/hosting-your-own-free-sexy-photo-gallery/</link>
		<comments>http://aaronhardy.com/php/hosting-your-own-free-sexy-photo-gallery/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 05:07:38 +0000</pubDate>
		<dc:creator>Aaron Hardy</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[photos]]></category>

		<guid isPermaLink="false">http://aaronhardy.com/?p=147</guid>
		<description><![CDATA[By sexy I mean good-looking but I knew using the words &#8220;free&#8221;, &#8220;sexy&#8221;, and &#8220;photo&#8221; in a post title would be worth at least 50 Google bonus points, so I couldn&#8217;t pass it up.  Here&#8217;s the premise of my post: 1) I have my own web server (which supports PHP). 2) I&#8217;m too cheap to [...]]]></description>
			<content:encoded><![CDATA[<p>By sexy I mean good-looking but I knew using the words &#8220;free&#8221;, &#8220;sexy&#8221;, and &#8220;photo&#8221; in a post title would be worth at least 50 Google bonus points, so I couldn&#8217;t pass it up.  Here&#8217;s the premise of my post:</p>
<p>1) I have my own web server (which supports PHP).</p>
<p>2) I&#8217;m too cheap to purchase good photo gallery software.</p>
<p>3) I&#8217;m too cheap to pay for photo-hosting services like Google Picasa or Flickr.</p>
<p>4) I want my photo gallery to be sexy (smooth, clean, silently loads upcoming photos, doesn&#8217;t have to load a new page for each photo, etc.).</p>
<p>5) I want my photo gallery to be able to support categories/events.</p>
<p>6) I want to be able to host hundreds of photos.</p>
<p>5) I want my photo gallery to be as hassle-free as possible.</p>
<p>So, after looking at my options, I found they were much more limited than I had hoped.  Don&#8217;t get me wrong&#8211;there were <a href="http://www.smashingmagazine.com/2007/05/18/30-best-solutions-for-image-galleries-slideshows-lightboxes/" target="_blank">a lot of options</a>, just not a lot of good ones.  In the end, I found a solution that seems to appease me for the time being.  Here&#8217;s the end result for all you instant-satisfaction-seekers: <a href="http://hardyhacienda.com/photos/ " target="_blank">http://hardyhacienda.com/photos/ </a></p>
<p><span id="more-147"></span></p>
<p>Now onto the good stuff.  The photo gallery takes advantage of <a href="http://www.airtightinteractive.com/simpleviewer/" target="_blank">SimpleViewer</a> made by <a href="http://www.airtightinteractive.com" target="_blank">Felix Turner/Airtight Interactive</a> as well as the <a href="http://www.google.com/picasa/" target="_blank">Google Picasa desktop application</a>. To start, follow the <a href="http://www.airtightinteractive.com/simpleviewer/picasa_instruct.html" target="_blank">SimpleViewer instructions</a> but stop after you get done with step #2.  Go ahead, I&#8217;ll wait.</p>
<p>Okay, now that you&#8217;ve got the SimpleViewer template installed, we want to tweak it just a bit.  Open up C:\Program Files\Picasa2\web\templates\simpleviewer_picasa_template\header.xml and change the contents to the following:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;simpleviewergallery</span> <span style="color: #000066;">maxImageWidth</span>=<span style="color: #ff0000;">&quot;1024&quot;</span> <span style="color: #000066;">maxImageHeight</span>=<span style="color: #ff0000;">&quot;1024&quot;</span> <span style="color: #000066;">textColor</span>=<span style="color: #ff0000;">&quot;0xFFFFFF&quot;</span> <span style="color: #000066;">frameColor</span>=<span style="color: #ff0000;">&quot;0xFFFFFF&quot;</span> <span style="color: #000066;">frameWidth</span>=<span style="color: #ff0000;">&quot;20&quot;</span> <span style="color: #000066;">stagePadding</span>=<span style="color: #ff0000;">&quot;40&quot;</span> <span style="color: #000066;">navPadding</span>=<span style="color: #ff0000;">&quot;40&quot;</span> <span style="color: #000066;">thumbnailColumns</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">thumbnailRows</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">navPosition</span>=<span style="color: #ff0000;">&quot;left&quot;</span> <span style="color: #000066;">vAlign</span>=<span style="color: #ff0000;">&quot;center&quot;</span> <span style="color: #000066;">hAlign</span>=<span style="color: #ff0000;">&quot;center&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;&lt;%exportDescription%&gt;</span></span>&quot; enableRightClickOpen=&quot;true&quot; backgroundImagePath=&quot;&quot; imagePath=&quot;&quot; thumbPath=&quot;thumbnails/&quot; albumDate=&quot;<span style="color: #009900;">&lt;%albumDate%<span style="color: #000000; font-weight: bold;">&gt;</span></span>&quot;&gt;</pre></div></div>

<p>Now restart Picasa.</p>
<p>What we&#8217;ve done here is added the albumDate property to our album template.  This means when we export an album from Picasa, Picasa will include a property in the album&#8217;s accompanying XML file stating the median date of when the album&#8217;s photos were taken.  This will later allow us to automatically order our albums according to the date.  Note that this date property is formatted as month/year only, so if you have two albums with median dates in the same month they may get sorted in the wrong order.  This is a limitation of Picasa that I feel Google should address.  The good news is that albums with median dates in different months will be sorted correctly.  Feel free to reference <a href="http://www.birchisland.info/docs/picasastuff/index.html" target="_blank">The Picasa Web Templating System</a> if you&#8217;re interested in learning more.</p>
<p>Now that we have our template configured correctly for our needs, continue with the remaining steps in the <a href="http://www.airtightinteractive.com/simpleviewer/picasa_instruct.html" target="_blank">SimpleViewer instructions</a>.</p>
<p>If you continue steps 3-6 for each album (what SimpleViewer calls gallery) you&#8217;d like to show up in your gallery, you&#8217;ll have all your albums on your web server.  At this point you can access each album individually by typing in the album&#8217;s address like <a href="http://hardyhacienda.com/photos/Yellowstone/" target="_blank">http://hardyhacienda.com/photos/Yellowstone/</a> or <a href="http://hardyhacienda.com/photos/Moab/" target="_blank">http://hardyhacienda.com/photos/Moab/</a> in your browser.  What we want though is a central gallery that then links to the individual albums.</p>
<p>Here&#8217;s how we do it.  Create a file named index.php on your web server in the directory that contains all your album directories.  Add the following to index.php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;html&gt;
	&lt;head&gt;
		&lt;title&gt;&lt;/title&gt;
		&lt;style&gt;
			body {
				background-color: #181818; 
				color: #ffffff;	
				font-family: &quot;Arial&quot;,Helvetica,sans-serif;
				font-size: .9em;
			}
&nbsp;
			h2 {
				font-family: &quot;Georgia&quot;,Times,serif;
				font-size: 22px;
				margin: 0px;
			}
&nbsp;
			ul {
				margin: 10px 0 0 0;
				padding: 0;
				border-bottom: 1px solid #3e3e3e;
			}
&nbsp;
			li {
				list-style-type: none;
				padding: 5px 0 5px 0;
				margin: 0;
				border-top: 1px solid #3e3e3e;
			}
&nbsp;
			a:link, a:visited, a:active {
				color: #00F6FE;
				text-decoration: none;
			}
&nbsp;
			a:hover {
				text-decoration: underline;
			}
		&lt;/style&gt;
	&lt;/head&gt;
	&lt;body&gt;
		&lt;div style=&quot;float:left; width: 20%; height: 100%; overflow: auto;&quot;&gt;
			&lt;div style=&quot;padding: 20px&quot;&gt;
				&lt;h2&gt;Galleries&lt;/h2&gt;
				&lt;ul&gt;
				<span style="color: #000000; font-weight: bold;">&lt;?</span>
&nbsp;
				<span style="color: #000088;">$albums</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$mydir</span> <span style="color: #339933;">=</span> <span style="color: #990000;">dir</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'./'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mydir</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;.&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;..&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
&nbsp;
						<span style="color: #000088;">$doc</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DOMDocument<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #000088;">$doc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;./<span style="color: #006699; font-weight: bold;">$file</span>/gallery.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #000088;">$albumDate</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span>
								<span style="color: #000088;">$doc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;simpleviewergallery&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>
								<span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;albumDate&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
						<span style="color: #000088;">$album</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
								<span style="color: #0000ff;">&quot;date&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$albumDate</span><span style="color: #339933;">,</span>
								<span style="color: #0000ff;">&quot;name&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
						<span style="color: #000088;">$albumInserted</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
						<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$albums</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
						<span style="color: #009900;">&#123;</span>
							<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$album</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$albums</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'date'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
							<span style="color: #009900;">&#123;</span>
								<span style="color: #000088;">$albumInserted</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
								<span style="color: #990000;">array_splice</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$albums</span><span style="color: #339933;">,</span> <span style="color: #000088;">$i</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$album</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</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: #009900;">&#125;</span>
&nbsp;
						<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$albumInserted</span><span style="color: #009900;">&#41;</span>
						<span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$albums</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$album</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$albums</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$album</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;li&gt;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>#<span style="color: #000099; font-weight: bold;">\&quot;</span> onclick=<span style="color: #000099; font-weight: bold;">\&quot;</span>frames['viewer'].location.href = '&quot;</span> <span style="color: #339933;">.</span> 
							<span style="color: #000088;">$album</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;'; return false;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$album</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/a&gt;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #000088;">$mydir</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">?&gt;</span>
				&lt;/ul&gt;
			&lt;/div&gt;
		&lt;/div&gt;
		&lt;div style=&quot;float:left; width: 80%; height: 100%&quot;&gt;
			&lt;iframe name=&quot;viewer&quot; src=&quot;directions.php&quot; style=&quot;float:left; width:100%; height:100%; border:0;&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;
		&lt;/div&gt;
	&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>What we&#8217;re doing here is making a menu on the left side of the page that contains links to each of our albums which also happen to be subdirectories.  We&#8217;re reading the gallery.xml file that accompanies each album to find the median date of the photos taken (thanks to our tweak to the SimpleViewer template).  We&#8217;re then sorting the albums by that date ordered from most recent to least recent and creating a link for each album.  On the right side of the page, we have an <a href="http://en.wikipedia.org/wiki/IFrame" target="_blank">iframe</a>.  This iframe will act as a container that will hold each album as it is loaded.</p>
<p>In my case, the iframe by default displays a directions.php page which essentially just instructs the user to select an album by clicking a link on the left side of the page.  When an album&#8217;s link is clicked, the directions.php page will be replaced by the album&#8217;s page in the iframe.  If everything was set up right, you should now be hosting your own free sexy photo gallery!</p>
<p>I know this isn&#8217;t the most comprehensive or detailed of posts, so if you have any feedback or questions, please feel free to post a comment.  Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://aaronhardy.com/php/hosting-your-own-free-sexy-photo-gallery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simple AMFPHP Example</title>
		<link>http://aaronhardy.com/flex/simple-amfphp-example/</link>
		<comments>http://aaronhardy.com/flex/simple-amfphp-example/#comments</comments>
		<pubDate>Mon, 11 Feb 2008 04:24:14 +0000</pubDate>
		<dc:creator>Aaron Hardy</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[amf]]></category>
		<category><![CDATA[AMFPHP]]></category>
		<category><![CDATA[serialization]]></category>

		<guid isPermaLink="false">http://intimateconversations.aaronhardy.com/php/simple-amfphp-example/</guid>
		<description><![CDATA[With the advent of Flex and RIA (Rich Internet Application) development came AMF (Action Message Format). Flex, in general, focuses only on front-end functionality, meaning it does not directly hit a database to store or retrieve persistent data. Instead, database calls are written in a more traditional back-end language like Java, PHP, Python, or .NET [...]]]></description>
			<content:encoded><![CDATA[<p>With the advent of Flex and RIA (Rich Internet Application) development came AMF (Action Message Format).  Flex, in general, focuses only on front-end functionality, meaning it does not directly hit a database to store or retrieve persistent data.  Instead, database calls are written in a more traditional back-end language like Java, PHP, Python, or .NET and such services are then exposed to be &#8220;consumed&#8221; (used) by the Flex front-end.</p>
<p>AMF is a protocol that allows ActionScript (the language of Flash/Flex) to call services exposed by the back-end.  Additionally, if you choose, AMF allows you to translate a programmer-defined object between ActionScript and your back-end language of choice.  In other words, if you have a customer class in ActionScript and you want to pass an instantiated customer object to the back-end, you simply call the exposed back-end service and pass the customer object as a parameter.  The AMF layer transparently translates the ActionScript customer object into, let&#8217;s say, a customer object in Java.  This functionality isn&#8217;t required.  Instead of using a class you have defined, you could instead just send an integer to the backend as a parameter and, after processing, send a string back to the front-end.<span id="more-33"></span></p>
<p>Before checking out my example, I recommend checking out the <a href="http://en.wikipedia.org/wiki/Action_Message_Format" target="_blank">Wikipedia Action Message Format article</a> to get a basic description of AMF and links to implementations for various back-end languages.  I also recommend reading <a href="http://nothinghappens.net/?p=198" target="_blank">AMFPHP class mapping explained</a> by Chuck Hoffman to get a good understanding of the object translation I just described.  Finally, head on over to <a href="http://amfphp.org/" target="_blank">amfphp.org</a> (the creators of AMFPHP) to get a glimpse of available documentation, files, etc.  I might add that if any of the folks over at amfphp.org don&#8217;t like me distributing AMFPHP code, let me know and I&#8217;ll modify the files I&#8217;ve posted for download.  The zip file below currently contains everything you&#8217;ll need to get a simple example up and running.  Now to the example&#8230;</p>
<p><a href='/wp-content/uploads/2008/02/simpleamfphp.zip' title='Simple AMFPHP Example'>Simple AMFPHP Example Zip File</a></p>
<p>For the example, I made a Kite Finder.  Basically, you enter in a kite pilot&#8217;s name and Flex populates a person object with the pilot name entered.  Flex then calls a PHP service function using AMFPHP which translates the ActionScript person object to a PHP person object on the backend.  In a real environment, you would then use information from the person object to hit a database to find the pilot&#8217;s kite.  In our example, we just build a kite object using dummy data.  Our PHP function then returns the kite object, which AMFPHP ships back to the Flex front-end, translating it to an ActionScript kite object.  In reality, the person and kite classes might be a little overboard for such a simple example.  I could&#8217;ve just passed two string parameters (the pilot&#8217;s first and last name) to the PHP function and an associative array (kite info) back to the front-end, but I wanted to demonstrate AMFPHP&#8217;s object translation.</p>
<p>Setting up the example is fairly easy:</p>
<ol>
<li>Upload the amfphp directory to the root directory of your website.</li>
<li>Open the SimpleAMFPHP project in FlexBuilder and modify the &#8220;gateway&#8221; variable in FindKiteCommand to point to your new gateway address.</li>
</ol>
<p>That&#8217;s all!  You should be able to deploy the project from within FlexBuilder and see it in action.  This should work even if you&#8217;re using <a href="http://www.hostingobserver.com" target="_blank">inexpensive web hosting</a>.  If you have questions on where code is, what&#8217;s happening, how to do something, or anything else, please&#8230;join the intimate conversation!</p>
]]></content:encoded>
			<wfw:commentRss>http://aaronhardy.com/flex/simple-amfphp-example/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Object-oriented PHP :: A guide for fellow ISys junkies</title>
		<link>http://aaronhardy.com/php/object-oriented-php-a-guide-for-fellow-isys-junkies/</link>
		<comments>http://aaronhardy.com/php/object-oriented-php-a-guide-for-fellow-isys-junkies/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 02:31:06 +0000</pubDate>
		<dc:creator>Aaron Hardy</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[object-oriented programming]]></category>
		<category><![CDATA[polymorphism]]></category>

		<guid isPermaLink="false">http://intimateconversations.aaronhardy.com/uncategorized/object-oriented-php-a-guide-for-fellow-isys-junkies/</guid>
		<description><![CDATA[I&#8217;m currently studying Information Systems at Brigham Young University where the main language being taught to students is Java, a very object-oriented language. Some students, after having learned Java, have difficulty making the jump from Java to PHP for one reason or another. While I do not profess to have reached the level of Zen [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently studying Information Systems at <a href="http://byu.edu" target="_blank">Brigham Young University</a> where the main language being taught to students is Java, a very object-oriented language.  Some students, after having learned Java, have difficulty making the jump from Java to PHP for one reason or another.  While I do not profess to have reached the level of Zen Master in PHP, I do hope I can provide some insight in a way that fellow ISys junkies can take what they&#8217;ve learned and pick up PHP if they want.<span id="more-19"></span>  As always, I&#8217;m open to improvements/corrections in my code, questions, complaints, I-could-do-it-better-than-yous, whatever.  So here we go!</p>
<p>First off, PHP has not always been an object-oriented language and has yet to become a &#8220;pure&#8221; object-oriented language (and probably won&#8217;t ever be&#8211;it&#8217;s good at filling a distinct niche somewhere between scripting and enterprise application development).  For example, you can still code in PHP without using objects at all.  Also, some object-oriented features that are available in other languages are still not available in PHP, like overloading (although supported, it&#8217;s not implemented the &#8220;standard&#8221; way we&#8217;re used to in other languages) and namespaces.  There are hacks that can allow for such functionality, but we&#8217;ll leave those alone for now.  In any case, PHP is still my friend and it can be yours too.</p>
<p>Before we get into the OO (object-oriented) code, I want to give a really short intro to a few PHP basics.  If you&#8217;ve already played with PHP, you&#8217;re probably safe to move onto the next page.</p>
<p><b>Defining a variable</b></p>
<p>In PHP, a variable is defined the following way:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$myVar</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;my string&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Notice I did not have to declare <i>$myVar</i> as a string before setting its value.  If you were to then set <i>$myVar = 6</i>, no conversion code on your part would be necessary; PHP would convert it from a string to an integer for you. That&#8217;s one of the beauties and the uglies of PHP, take it or leave it.  Every variable name must be preceded with a dollar sign (we&#8217;ll see somewhat of an exception on the next page.)  PHP is also case-sensitive, so be sure you take care of capitalization.</p>
<p><b>Outputting to the browser</b><br />
To output something on the user&#8217;s browser, use the <i>echo</i> command:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;A test.&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$myVar</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The first line prints <i>A test.</i> while the second line prints whatever is stored in your <i>$myVar</i> variable.</p>
<p><b>Concatenation and variable interpretation</b></p>
<p>Because we precede every variable name with a dollar sign, PHP can easily tell what&#8217;s a variable and what&#8217;s not.  Let&#8217;s look at some code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;John Doe&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hello, <span style="color: #006699; font-weight: bold;">$name</span>!  Welcome to my website.&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hello, &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;! Welcome to my website.&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Hello, $name! Welcome to my website.&lt;br /&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Hello, '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'! Welcome to my website.&lt;br /&gt;'</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This outputs the following:<br />
<code><br />
Hello, John Doe! Welcome to my website.<br />
Hello, John Doe! Welcome to my website.<br />
Hello, $name! Welcome to my website.<br />
Hello, John Doe! Welcome to my website.<br />
</code></p>
<p>In our code, using double-quotes tells PHP to interpret our variables and spit out their values.  On the other hand, using single-quotes tells PHP not to interpret variables, which is why our third output line came out the way it did.  Finally, using a period  (.) lets you concatenate the same way that you would using the plus sign (+) in Java.  Usually we&#8217;ll want to use our first method unless there&#8217;s a compelling reason not to.</p>
<p>Now to the fun stuff&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://aaronhardy.com/php/object-oriented-php-a-guide-for-fellow-isys-junkies/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

