<?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>Aaron As a Chimp &#187; php</title>
	<atom:link href="http://sachimp.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://sachimp.com</link>
	<description>with a typewriter</description>
	<lastBuildDate>Sat, 18 Jun 2011 15:26:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Barbeque: A brainstorm on better Data interfaces</title>
		<link>http://sachimp.com/2009/07/06/barbeque-a-brainstorm-on-better-data-interfaces/</link>
		<comments>http://sachimp.com/2009/07/06/barbeque-a-brainstorm-on-better-data-interfaces/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 00:46:38 +0000</pubDate>
		<dc:creator>AaronAsAChimp</dc:creator>
				<category><![CDATA[Ideas]]></category>
		<category><![CDATA[bbQuery]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://sachimp.com/?p=89</guid>
		<description><![CDATA[So, with the release of PHP 5.3 some of the new features got me thinking about better ways to query and interact with data. I&#8217;m tentatively calling it bbQuery, or bbQ for short. Data Driven Apps Web applications are typically driven by data and interactions between it. A typical situation involves: Querying data from the [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><p>So, with the release of <a href="http://www.php.net/archive/2009.php#id2009-06-30-1">PHP 5.3</a> some of the new features got me thinking about better ways to query and interact with data.  I&#8217;m tentatively calling it <strong>bbQuery</strong>, or <strong>bbQ</strong> for short.</p>
<h3>Data Driven Apps</h3>
<p>Web applications are typically driven by<strong> data </strong>and interactions<strong> between it</strong>.  A typical situation involves: Querying data from the database, formatting as HTML, outputting.  A few years ago it was just that simple.  <strong>Today</strong> you have JSON, RSS, and other various formats.</p>
<p>Going by the standard model, you have to create <strong>each</strong> page <strong>separately</strong> for all of the various formats, duplicating code.  I can&#8217;t say I solved this problem entirely, but I&#8217;m getting close.</p>
<h3>Grab the Steaks, It&#8217;s Time for a bbQ</h3>
<p>The goal is to be <strong>functionally similar</strong> to SQL but include a formatting layer that <strong>intelligently</strong> determines the way to display the data.  The following snippet show how the old model can be transitioned to bbQ.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$DB</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Children'</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'children_id'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dob'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fitness'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'status'</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">${row['dob']}</span> - <span style="color: #006699; font-weight: bold;">${row['fitness']}</span> - <span style="color: #006699; font-weight: bold;">${row['status']}</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>A simple example using the <a href="http://github.com/AaronAsAChimp/gfonted/blob/692129f6bb5bad40e302b98010358a95c08d32a2/db.sql">gFonted database</a>.  The first line selects the table from the database.  On the second we select the columns we want in the query.  The query results are then returned in to a callback from the format function.  Very quickly you could create predefined formatting functions.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$DB</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Children'</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*'</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">left_join</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Template'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'children_id'</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span>bbQuery<span style="color: #339933;">::</span><span style="color: #004000;">format_table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// predefined format functions</span></pre></div></div>

<p>But thats far from automatic, intelligent maybe.  Its impossible to guess what format anyone will need.  There are a few generic formats (JSON and XML) that could be dealt with automatically.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$DB</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Children'</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*'</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">left_join</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Template'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'children_id'</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">limit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">order_by</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'fitness'</span><span style="color: #339933;">,</span> bbQuery<span style="color: #339933;">::</span><span style="color: #004000;">asc</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// bbQuery::asc == &quot;asc&quot;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_type</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/json&quot;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$DB</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Children'</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*'</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">left_join</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Template'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'children_id'</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">limit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// is a variable that gets overwritten</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">order_by</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'fitness'</span><span style="color: #339933;">,</span> bbQuery<span style="color: #339933;">::</span><span style="color: #004000;">desc</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// order by's are string</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">order_by</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dob'</span><span style="color: #339933;">,</span> bbQuery<span style="color: #339933;">::</span><span style="color: #004000;">asc</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// and gets appended to</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_type</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/xml&quot;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Going the Other Direction</h3>
<p>Sometimes its useful to put data into a database.  I guess thats an understatement.  Its also an understatement to say that doing so is a simple task.  An example of standard data insertion:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$DB</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Correct'</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">insert_into</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'children_id'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'correct'</span><span style="color: #009900;">&#41;</span>  <span style="color: #666666; font-style: italic;">// returns an insert object</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">values</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>However this could be greatly simplified.  MySQL already knows the datatype for the column, so validation could be automated.  The data could even be automatically inserted from a form.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;form&gt;
   &lt;input name=&quot;children_id&quot; type=&quot;text&quot; value=&quot;12&quot; /&gt;
   &lt;input name=&quot;correct&quot; type=&quot;checkbox&quot; /&gt;
&lt;/form&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$DB</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Children'</span><span style="color: #009900;">&#93;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">insert_into</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'children_id'</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">'correct'</span><span style="color: #009900;">&#41;</span>  <span style="color: #666666; font-style: italic;">// returns an insert object</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">from_form</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></pre></div></div>

<p>And finally some other useful snippets:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$DB</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;select * from Children&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span>bbQuery<span style="color: #339933;">::</span><span style="color: #004000;">format_table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$DB</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test'</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">create_table</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// returns a create_table object</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">column</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test_id'</span><span style="color: #339933;">,</span> bbQuery<span style="color: #339933;">::</span><span style="color: #004000;">id_column</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// id is special if set as a primary key, unsigned integer autoincrement</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">column</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test_foreign_id'</span><span style="color: #339933;">,</span> bbQuery<span style="color: #339933;">::</span><span style="color: #004000;">id_column</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// just a unsigned integer</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">column</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test_char'</span><span style="color: #339933;">,</span> bbQuery<span style="color: #339933;">::</span><span style="color: #004000;">char_column</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// field length as parameter</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">column</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test_int'</span><span style="color: #339933;">,</span> bbQuery<span style="color: #339933;">::</span><span style="color: #004000;">integer_column</span><span style="color: #009900;">&#40;</span>bbQuery<span style="color: #339933;">::</span><span style="color: #004000;">big</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// default as third parameter to column</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">column</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test_enum'</span><span style="color: #339933;">,</span> bbQuery<span style="color: #339933;">::</span><span style="color: #004000;">enum_column</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'val'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'val3'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'val2'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// enum is varidaic</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">primary_key</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test_id'</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">foreign_key</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test_foreign_id'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Correct'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$DB</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test'</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">alter_table</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// returns a alter_table object</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test_timestamp'</span><span style="color: #339933;">,</span> bbQuery<span style="color: #339933;">::</span><span style="color: #004000;">timestamp_column</span><span style="color: #339933;">,</span> bbQuery<span style="color: #339933;">::</span><span style="color: #004000;">now</span><span style="color: #009900;">&#41;</span>
   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">drop</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test_int'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$DB</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;truncate table test&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// format is not appropriate here</span></pre></div></div>

<div class="shr-publisher-89"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fsachimp.com%2F2009%2F07%2F06%2Fbarbeque-a-brainstorm-on-better-data-interfaces%2F' data-shr_title='Barbeque%3A+A+brainstorm+on+better+Data+interfaces'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fsachimp.com%2F2009%2F07%2F06%2Fbarbeque-a-brainstorm-on-better-data-interfaces%2F' data-shr_title='Barbeque%3A+A+brainstorm+on+better+Data+interfaces'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://sachimp.com/2009/07/06/barbeque-a-brainstorm-on-better-data-interfaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dr. JavaScript and Mr. PHP</title>
		<link>http://sachimp.com/2009/01/21/dr-javascript-and-mr-php/</link>
		<comments>http://sachimp.com/2009/01/21/dr-javascript-and-mr-php/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 00:27:40 +0000</pubDate>
		<dc:creator>AaronAsAChimp</dc:creator>
				<category><![CDATA[Sachimp Labs]]></category>
		<category><![CDATA[Billy Hoffman]]></category>
		<category><![CDATA[Hak .5]]></category>
		<category><![CDATA[hybrid code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://sachimp.com/?p=35</guid>
		<description><![CDATA[In my last post I wrote about JavaScript variables.  It stemmed from realizing that the dollar sign ($) was a valid character in JavaScript.  I struggled to find any use for all of these new characters – other than making code unreadable.  One thing stuck out in my mind.  An old episode of Hak .5 where [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><p>In my <a title="The many lives of JavaScript variables" href="/2008/12/13/javascript-variables/">last post</a> I wrote about JavaScript variables.  It stemmed from realizing that the dollar sign ($) was a valid character in JavaScript.  I struggled to find any use for all of these new characters – other than making code unreadable.  One thing stuck out in my mind.  An <a href="http://www.hak5.org/episodes/episode-2x09-release">old episode of Hak .5</a> where Billy Hoffman described a <a href="http://en.wikipedia.org/wiki/Computer_worm">worm</a> that would be written in a hybrid of Perl and JavaScript.  A <em>Dr. Jekyll and Mr. Hyde</em> scenario where the worm would embed itself in a web page and search for a &#8220;host&#8221;, and then infect that host.  That host would then serve pages with the worm embedded in it, creating exponential growth.  Unfortunately at the time he didn&#8217;t have a proof of concept.</p>
<h3>Hybrid Means Better Gas Mileage</h3>
<p>Unlike Billy&#8217;s technique I chose to use PHP instead of Perl.  Many of the language constructs are identical between PHP and JavaScript.  However there are few snags.</p>
<ul>
<li>PHP scripts have to start and end with &#8216;&lt;?&#8217; and &#8216;?&gt;&#8217; respectively.</li>
<li>PHP variables must start with a &#8216;$&#8217;.</li>
<li>Most of JavaScript&#8217;s standard functions are wrapped in objects.  Math, String, etc.</li>
<li>PHP uses the &#8216;.&#8217; for concatenation, while JavaScript uses &#8216;+&#8217;.</li>
<li>PHP uses C++ style definition for objects, while JavaScript uses a prototype definition.</li>
<li>JavaScript uses the C++ style const keyword to define constants, while PHP uses the define() function.</li>
</ul>
<h3>The Lucky Ones</h3>
<p>Not all of these problems can be worked around, but enough of them can be worked around that functioning code can be written.</p>
<dl>
<dt>PHP scripts have to start and end with &#8216;&lt;?&#8217; and &#8216;?&gt;&#8217; respectively.</dt>
<dd>The workaround for this is to run the script using the eval() function.  The PHP&#8217;s eval() function doesn&#8217;t require the opening and closing tags as feature.</dd>
<dt>PHP variables must start with a &#8216;$&#8217;.</dt>
<dd>The dollar sign is a valid character in JavaScript variables, so starting them with the dollar sign poses no problem.</dd>
<dt>Most of JavaScript&#8217;s standard functions are wrapped in objects.  Math, String, etc.</dt>
<dd><a title="PHP.js" href="http://phpjs.org/">PHP.js</a> can be used to wrap the standard JavaScript functions.  Acting as a compatibility layer.</dd>
<dt>JavaScript uses the C++ style const keyword to define constants, while PHP uses the define() function.</dt>
<dd>PHP version 5.3.0 allows for the const keyword.</dd>
</dl>
<h3>Taking the Plunge</h3>
<p>As a proof of concept I wrote a small function to calculate  the <a href="http://en.wikipedia.org/wiki/Great-circle_distance">great circle distance</a>.  It computes the distance in both PHP and JavaScript.  You can find it <a href="http://sachimp.com/labs/dualcode/">here</a> and hybrid PHP / JavaScript code <a href="http://sachimp.com/labs/dualcode/dualcode.js">here</a>.</p>
<div class="shr-publisher-35"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fsachimp.com%2F2009%2F01%2F21%2Fdr-javascript-and-mr-php%2F' data-shr_title='Dr.+JavaScript+and+Mr.+PHP'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fsachimp.com%2F2009%2F01%2F21%2Fdr-javascript-and-mr-php%2F' data-shr_title='Dr.+JavaScript+and+Mr.+PHP'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://sachimp.com/2009/01/21/dr-javascript-and-mr-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

