<?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>Alex Little &#187; PHP</title>
	<atom:link href="http://alexlittle.net/blog/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://alexlittle.net/blog</link>
	<description></description>
	<lastBuildDate>Thu, 09 Feb 2012 10:34:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Blog now OpenID enabled</title>
		<link>http://alexlittle.net/blog/2009/06/15/blog-now-openid-enabled/</link>
		<comments>http://alexlittle.net/blog/2009/06/15/blog-now-openid-enabled/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 10:49:32 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Social Software]]></category>
		<category><![CDATA[openid]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://alexlittle.net/blog/?p=1063</guid>
		<description><![CDATA[I&#8217;ve finally got around to allowing you to post a comment using an OpenID, by installing one of the WordPress OpenID plugins. I had tried to do this over a year ago, but couldn&#8217;t quite get it working correctly. I had a number of problems before, notably that my hosting server only ran PHP4, whereas [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve finally got around to allowing you to post a comment using an OpenID, by installing one of the <a href="http://wordpress.org/extend/plugins/openid/">WordPress OpenID plugins</a>.</p>
<p>I had tried to do this over a year ago, but couldn&#8217;t quite get it working correctly. I had a number of problems before, notably that my hosting server only ran PHP4, whereas (at the time) most OpenID plugins seemed designed for PHP5, or a specific version of PHP4 that I wasn&#8217;t running. The other main factor was that most of the OpenID plugins at the time were very early (beta or earlier) versions, so may have been a little buggy still, whereas the plugin I installed today was very easy to get set up and running.</p>
<p>Anyone using a verified OpenID to post a comment on this site will find that their name and email is not required, plus your comments skip moderation.</p>
<p>Please let me know if you find any problems in using your OpenID on this site.</p>
]]></content:encoded>
			<wfw:commentRss>http://alexlittle.net/blog/2009/06/15/blog-now-openid-enabled/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>REST Service documentation with PHPDocumentor</title>
		<link>http://alexlittle.net/blog/2008/04/14/rest-service-docs-with-phpdocumentor/</link>
		<comments>http://alexlittle.net/blog/2008/04/14/rest-service-docs-with-phpdocumentor/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 08:47:07 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Web dev & programming]]></category>
		<category><![CDATA[cohere]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpdocumentor]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://alexlittle.net/blog/?p=335</guid>
		<description><![CDATA[I&#8217;ve just been hacking around with PHPDocumentor getting it to automatically create the documentation for the Cohere API and seems to be working well. I have apilib.php which contains the PHP calls to the functions, then service.php is a wrapper around the apilib.php and provides the actual REST based services. Service.php is basically just a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just been hacking around with <a href="http://www.phpdoc.org/">PHPDocumentor</a> getting it to automatically create the documentation for the <a href="http://cohere.open.ac.uk">Cohere</a> API and seems to be working well.</p>
<p>I have apilib.php which contains the PHP calls to the functions, then service.php is a wrapper around the apilib.php and provides the actual REST based services. Service.php is basically just a big switch statement, so, since PHPDocumentor needs the function declarations I can&#8217;t actually base the service documentation on service.php, so I&#8217;m using apilib.php as the basis for the service documentation.</p>
<p>I created my own PHPDocumentor template, which has been straightforward enough, though I did come across a couple of <a href="http://sourceforge.net/forum/forum.php?thread_id=2004248&amp;forum_id=35065">little issues</a> &#8211; nothing too big and nothing that can&#8217;t be worked around .</p>
<p>These were the 2 little hacks I needed to put into my template:</p>
<ol>
<li>in apilib, I&#8217;ve named the functions using camel case, whereas the actual method calls in service.php need to be lower case &#8211; so I amended the stylesheet to use: {text-transform:lowercase;} where the function name was displayed</li>
<li>I also needed to remove the dollar signs from the front of all the PHP parameters, so to do this I just used the Smarty templating command &#8216;replace&#8217;: {$functions[func].params[params].var|replace:&#8217;$':&#8221;}</li>
</ol>
<p>I still have some of the documentation to actually write into apilib.php &#8211; most notably example service calls for each method and double checking the return descriptions are consistent (and correct). All is working out well and you can see the <a href="http://cohere.open.ac.uk/api/_apilib.php.html">generated docs</a> on the Cohere site.</p>
]]></content:encoded>
			<wfw:commentRss>http://alexlittle.net/blog/2008/04/14/rest-service-docs-with-phpdocumentor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP arrays &amp; recordsets to Javascript Objects (JSON)</title>
		<link>http://alexlittle.net/blog/2006/12/15/php-arrays-recordsets-to-javascript-objects-json/</link>
		<comments>http://alexlittle.net/blog/2006/12/15/php-arrays-recordsets-to-javascript-objects-json/#comments</comments>
		<pubDate>Fri, 15 Dec 2006 10:04:41 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Web dev & programming]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexlittle.net/blog/2006/12/15/php-arrays-recordsets-to-javascript-objects-json/</guid>
		<description><![CDATA[Whilst writing the code for our MSG-Moodle integration, I needed to write a couple of helper functions to turn PHP arrays and ADOdb recordsets into JSON objects, and thought other might find them useful, so here they are: This one takes an associative array of objects to turn into JSON object: /** * @param $objects [...]]]></description>
			<content:encoded><![CDATA[<p>Whilst writing the code for our MSG-Moodle integration, I needed to write a couple of helper functions to turn PHP arrays and ADOdb recordsets into JSON objects, and thought other might find them useful, so here they are:</p>
<p>This one takes an associative array of objects to turn into JSON object:<br />
<code><br />
/**<br />
* @param $objects object to turn into JSON<br />
* @param $name overall name of the JSON object<br />
* @param $callback name of the callback function<br />
* @return string of the JSON object<br />
*/<br />
function phpToJSON($objects,$name,$callback=''){<br />
    $str = '';<br />
    if ($callback != ''){<br />
        $str .= $callback.'(';<br />
    }<br />
    if ($objects){<br />
        $str .= '{"'.$name.'":[';<br />
        $okeys = array_keys($objects);<br />
        for ($i=0; $i&lt; sizeof($okeys); $i++){<br />
            $myobj = $objects[$okeys[$i]];<br />
            $attr = get_object_vars($myobj);<br />
            $str .= '{';<br />
            $keys = array_keys($attr);<br />
            for($j=0;$j&lt; sizeof($keys); $j++){<br />
                $str .= '"'. $keys[$j] .'":"'. $attr[$keys[$j]] .'"';<br />
                if ($j != (sizeof($keys)-1)){<br />
                    $str .= ',';<br />
                }<br />
            }<br />
            $str .= '}';<br />
            if ($i != (sizeof($objects)-1)){<br />
            $str .= ',';<br />
        }<br />
    }<br />
    $str .= ']}';<br />
}<br />
if ($callback != ''){<br />
$str .= ');';<br />
}<br />
return $str;<br />
}<br />
</code><br />
and this one takes an ADOdb recordset and turns it into JSON object:<br />
<code><br />
/**<br />
* @param $objects object to turn into JSON<br />
* @param $name overall name of the JSON object<br />
* @param $callback name of the callback function<br />
* @return string of the JSON object<br />
*/<br />
function phpRSToJSON($rs,$name,$callback=''){<br />
$str = '';<br />
if ($callback != ''){<br />
$str .= $callback.'(';<br />
}<br />
if ($rs){</p>
<p>$str .= '{"'.$name.'":[';</p>
<p>$i=0;<br />
while(!$rs->EOF) {<br />
$i++;<br />
$str .= '{';<br />
$keys = array_keys($rs->fields);<br />
for($j=0;$j<sizeof ($keys);$j++){<br />
$str .= '"'. $keys[$j] .'":"'. $rs->fields[$keys[$j]] .'"';<br />
if ($j != (sizeof($keys)-1)){<br />
$str .= ',';<br />
}<br />
}<br />
$str .= '}';<br />
if ($i != $rs->RecordCount()){<br />
$str .= ',';<br />
}<br />
$rs->MoveNext();<br />
}</p>
<p>$str .= ']}';<br />
}<br />
if ($callback != ''){<br />
$str .= ');';<br />
}<br />
return $str;<br />
}<br />
</sizeof></code><br />
Hope you find these useful, and if you spot anything wrong (or that could be done better!) &#8211; please feel free to let me know <img src='http://alexlittle.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://alexlittle.net/blog/2006/12/15/php-arrays-recordsets-to-javascript-objects-json/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Curious handling of timeout by fsockopen??</title>
		<link>http://alexlittle.net/blog/2006/10/05/curious-handling-of-timeout-by-fsockopen/</link>
		<comments>http://alexlittle.net/blog/2006/10/05/curious-handling-of-timeout-by-fsockopen/#comments</comments>
		<pubDate>Thu, 05 Oct 2006 14:49:36 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Web dev & programming]]></category>
		<category><![CDATA[fsockopen]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexlittle.net/blog/2006/10/05/curious-handling-of-timeout-by-fsockopen/</guid>
		<description><![CDATA[We&#8217;ve been finding that sometimes my code using fsockopen doesn&#8217;t appear to be timing out in the given timeout period and I think I&#8217;ve tracked down the reason&#8230; Essentially what&#8217;s been happening is that if the remote url is accessible (i.e. an fsockopen connection can be made to it), but the remote url takes a [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve been finding that sometimes my code using fsockopen doesn&#8217;t appear to be timing out in the given timeout period and I think I&#8217;ve tracked down the reason&#8230;</p>
<p>Essentially what&#8217;s been happening is that if the remote url is accessible (i.e. an fsockopen connection can be made to it), but the remote url takes a long time to respond, then the connection will just hang until a response is given &#8211; even if this exceeds the given timeout setting.</p>
<p>So if I have my timeout set to 10 seconds, but the remote URL takes 15 seconds to give a response, the script will NOT timeout after 10 seconds, instead it will wait until the remote URL responds. So my impression is that the timeout setting is only a connection timeout, not a general timeout &#8211; which was contrary to how I thought the timeout setting functioned. Thinking about if after this kinda makes sense, as the timeout is only on opening the connection, not on fopen &#8211; so it can&#8217;t know the remote url is taking longer than expected to respond.</p>
<p>As I can&#8217;t see a way to set a &#8216;real&#8217; timeout on an fsock or fopen connection, I had a go using the cURL library. This appears to work in the way I expected &#8211; i.e. setting a timeout of 10 seconds would mean the script would stop after 10 seconds as the remote URL had not responded.</p>
]]></content:encoded>
			<wfw:commentRss>http://alexlittle.net/blog/2006/10/05/curious-handling-of-timeout-by-fsockopen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thursday 10 August 06</title>
		<link>http://alexlittle.net/blog/2006/08/10/thursday-10-august-06/</link>
		<comments>http://alexlittle.net/blog/2006/08/10/thursday-10-august-06/#comments</comments>
		<pubDate>Thu, 10 Aug 2006 10:55:58 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Web dev & programming]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[openlearn]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexlittle.net/blog/2006/08/10/thursday-10-august-06/</guid>
		<description><![CDATA[I&#8217;ve just got my new laptop so am getting all the bits and bobs installed on here that I&#8217;ll need for the OCI work. I&#8217;m going through the process of installing Apache, MySQL, PHP etc (I&#8217;d prefer to do this myself than to use one of the all-in-one installers, just so I know how it [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just got my new laptop so am getting all the bits and bobs installed on here that I&#8217;ll need for the OCI work. I&#8217;m going through the process of installing Apache, MySQL, PHP etc (I&#8217;d prefer to do this myself than to use one of the all-in-one installers, just so I know how it all really works!). nearly there with it now, just a couple of things I noticed on various forums etc about getting PHP5 to work with Apache 2.2, a fair few forum postings mention downloading php5apache2_2.dll to use instead of php5apache2.dll. I found that I didn&#8217;t need to do this, and instead of adding a LoadModule command to the Apache httpd.conf file, I just added this at the end instead:</p>
<p>ScriptAlias /php/ &#8220;c:/PHP/&#8221;</p>
<p>AddType application/x-httpd-php .php .php5</p>
<p>Action application/x-httpd-php &#8220;/php/php-cgi.exe&#8221;</p>
<p>SetEnv PHPRC &#8220;C:/php&#8221;</p>
<p>I then also needed to update the directory security section in the httpd.conf file too, to allow Apache access to the PHP directory.</p>
<p>For info, <a href="http://www.tanguay.at/installPhp5.php5">this was the best tutorial</a> I found for getting all this set up &#8211; although it&#8217;s for MySQL 4.1, it still holds for MySQL 5.</p>
]]></content:encoded>
			<wfw:commentRss>http://alexlittle.net/blog/2006/08/10/thursday-10-august-06/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Thursday 20 July 06</title>
		<link>http://alexlittle.net/blog/2006/07/20/thursday-20-july-06/</link>
		<comments>http://alexlittle.net/blog/2006/07/20/thursday-20-july-06/#comments</comments>
		<pubDate>Thu, 20 Jul 2006 09:52:02 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Web dev & programming]]></category>
		<category><![CDATA[moodle]]></category>
		<category><![CDATA[msg]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexlittle.net/blog/2006/07/20/thursday-20-july-06/</guid>
		<description><![CDATA[Been looking further into creating a Moodle block for the MSG tool, and started to do a little bit of coding now. But soon came across the cross-domain problem when using XmlHttpRequest &#8211; in that you can&#8217;t make an AJAX request from one domain to another (well, not without the user lowering their browser security [...]]]></description>
			<content:encoded><![CDATA[<p>Been looking further into creating a Moodle block for the MSG tool, and started to do a little bit of coding now. But soon came across the cross-domain problem when using XmlHttpRequest &#8211; in that you can&#8217;t make an AJAX request from one domain to another (well, not without the user lowering their browser security levels on their machine first &#8211; which wouldn&#8217;t be a good plan!)</p>
<p>So it looks like we&#8217;ve got 3 options: 1, install the software on the same server so the url is the same and everything will be happy, 2, make proxy http calls, or 3, use frames/iframes. Option 3 is pretty much ruled out straight away, and I;ve gone for testing out option 2 (as I&#8217;m not sure if we&#8217;ll be able to run the buddy space service on the same machine as Moodle).</p>
<p>So my first task for this was to figure out how to make http requests in PHP, for this I needed pear installed. I&#8217;d read that pear was included with PHP 5 but jsut needed activating, but I didn&#8217;t have go-pear.bat in my PHP installation. This was because I&#8217;d just downloaded the PHP 5 installer rather than the PHP 5 zip package. So I downloaded the zip package and unpacked over the top of my existing PHP 5 install (overwriting any files) and that appears to have worked fine, as I now have the go-pear.bat and necessary extensions &#8211; just need to actually install them now!</p>
]]></content:encoded>
			<wfw:commentRss>http://alexlittle.net/blog/2006/07/20/thursday-20-july-06/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thursday 6 April 06</title>
		<link>http://alexlittle.net/blog/2006/04/06/thursday-6-april-06/</link>
		<comments>http://alexlittle.net/blog/2006/04/06/thursday-6-april-06/#comments</comments>
		<pubDate>Thu, 06 Apr 2006 08:24:14 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Web dev & programming]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://alexlittle.net/blog/2006/04/06/thursday-6-april-06/</guid>
		<description><![CDATA[Follow up discussion about the question of how to (or not to do!) XML parsing in different versions of PHP: http://moodle.org/mod/forum/discuss.php?d=43241]]></description>
			<content:encoded><![CDATA[<p>Follow up discussion about the question of how to (or not to do!) XML parsing in different versions of PHP: <a href="http://moodle.org/mod/forum/discuss.php?d=43241">http://moodle.org/mod/forum/discuss.php?d=43241</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alexlittle.net/blog/2006/04/06/thursday-6-april-06/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wednesday 5 April 06</title>
		<link>http://alexlittle.net/blog/2006/04/05/wednesday-5-april-06/</link>
		<comments>http://alexlittle.net/blog/2006/04/05/wednesday-5-april-06/#comments</comments>
		<pubDate>Wed, 05 Apr 2006 13:46:38 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Web dev & programming]]></category>
		<category><![CDATA[enterprise sdk]]></category>
		<category><![CDATA[joinin]]></category>
		<category><![CDATA[moodle]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[webservice]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://alexlittle.net/blog/2006/04/05/wednesday-5-april-06/</guid>
		<description><![CDATA[Getting on well with the development of the webservices for the Enterprise databases, and ought to have this about finished later this week. Then next week I can look at seeing how this maps across to the Enterprise SDK &#8211; I can use the same database and should to be able to reuse a lot [...]]]></description>
			<content:encoded><![CDATA[<p>Getting on well with the development of the webservices for the Enterprise databases, and ought to have this about finished later this week. Then next week I can look at seeing how this maps across to the Enterprise SDK &#8211; I can use the same database and should to be able to reuse a lot of the code too (esp the parts that make calls to the database to retrieve data).</p>
<p>Another thing we&#8217;ve been looking at at is how we&#8217;ll do the XML parsing in Moodle using php. Most Moodle installations run on PHP 4 which doesn&#8217;t have built in XML functions, whereas PHP 5 does. There are libraries available for PHP 4 to do the XML parsing, but these (I think) would mean rewriting the code if we (and/or Moodle) moved to PHP 5. The alternative (so code didn&#8217;t need to be rewritten for different versions of PHP) would be to use regular expressions on the XML string &#8211; but that seems like a bit of a kludge to me!</p>
]]></content:encoded>
			<wfw:commentRss>http://alexlittle.net/blog/2006/04/05/wednesday-5-april-06/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.702 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-10 10:15:55 -->

