<?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>Divide and Conquer &#187; PHP</title>
	<atom:link href="http://www.divideandconquer.se/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.divideandconquer.se</link>
	<description>David's Software Development Blog</description>
	<lastBuildDate>Thu, 24 Jun 2010 13:47:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>fmod() in PHP is the worst !&#8221;#¤%&amp;/()= function ever!</title>
		<link>http://www.divideandconquer.se/2009/11/10/fmod-in-php-is-the-worst-function-ever/</link>
		<comments>http://www.divideandconquer.se/2009/11/10/fmod-in-php-is-the-worst-function-ever/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 19:50:27 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Web developmnet]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/?p=580</guid>
		<description><![CDATA[I hate floating point artithmetic and I really hate fmod() in PHP. It&#8217;s useless.

fmod — Returns the floating point remainder (modulo) of the division   of the arguments

If you calculate 36 modulo 7.2?  What do you get? Zero, yes. 7.2*5=36. No remainder!
What if you use fmod in PHP? 

$ php -r 'echo fmod(36,7.2);'
7.2

WTF? Excuse [...]]]></description>
			<content:encoded><![CDATA[<p class="refpurpose"><span class="dc-title">I hate floating point artithmetic and I really hate fmod() in PHP. It&#8217;s useless.</span></p>
<blockquote>
<p class="refpurpose"><a href="http://php.net/fmod" onclick="pageTracker._trackPageview('/outgoing/php.net/fmod?referer=');"><span class="refname">fmod</span></a> — <span class="dc-title">Returns the floating point remainder (modulo) of the division   of the arguments</span></p>
</blockquote>
<p class="refpurpose"><span class="dc-title">If you calculate 36 modulo 7.2?  What do you get? Zero, yes. 7.2*5=36. No remainder!</span></p>
<p class="refpurpose"><span class="dc-title">What if you use fmod in PHP? </span></p>
<blockquote>
<pre class="refpurpose"><span class="dc-title">$ php -r 'echo fmod(36,7.2);'
7.2</span></pre>
</blockquote>
<p>WTF? Excuse me? Is that the result from IEEE 754 hell, a parallel universe, or what?</p>
<p>Now I&#8217;m betting on the function below. I hope it won&#8217;t let me down.</p>
<blockquote><p><code><span class="html">function modulo($n,$b) {<br />
return $n-$b*floor($n/$b);<br />
}</span></code></p>
<p><span class="html"><br />
</span></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2009/11/10/fmod-in-php-is-the-worst-function-ever/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Today&#8217;s thoughts about programming languages</title>
		<link>http://www.divideandconquer.se/2009/09/16/todays-thoughts-about-programming-languages/</link>
		<comments>http://www.divideandconquer.se/2009/09/16/todays-thoughts-about-programming-languages/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 19:48:31 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JRuby]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/?p=551</guid>
		<description><![CDATA[Maybe some of you have heard me ranting about this already?

I&#8217;m not productive enough in C++ and I feel too limited by Java
A large chunk of Java frameworks seem to serve no other purpose than to workaround limitations in Java
I believe (and hope!) that Java will cease to be the default language in the non-Microsoft [...]]]></description>
			<content:encoded><![CDATA[<p>Maybe some of you have heard me ranting about this already?</p>
<ul>
<li>I&#8217;m not productive enough in C++ and I feel too limited by Java</li>
<li>A large chunk of Java frameworks seem to serve no other purpose than to workaround limitations in Java</li>
<li>I believe (and hope!) that Java will cease to be the default language in the non-Microsoft world, and that other JVM-based languages such as Scala, Groovy and JRuby will become more important</li>
<li>How can I convince a client to allow  Scala, Groovy or JRuby in a project?</li>
<li>I should really get some C# experience!</li>
<li>It seems like I almost always resolve to PHP when I need to get something done quickly&#8230; which reminds me of an upcoming blog post about a recent fight with <a href="http://php.net/manual/en/class.soapserver.php" onclick="pageTracker._trackPageview('/outgoing/php.net/manual/en/class.soapserver.php?referer=');">SoapServer</a> and <a href="http://php.net/manual/en/book.simplexml.php" onclick="pageTracker._trackPageview('/outgoing/php.net/manual/en/book.simplexml.php?referer=');">SimpleXML</a> to implement WSSE UsernameToken authentication.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2009/09/16/todays-thoughts-about-programming-languages/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Online PHP MySQL CRUD Scaffold generator</title>
		<link>http://www.divideandconquer.se/2009/07/06/online-php-mysql-crud-scaffold-generator/</link>
		<comments>http://www.divideandconquer.se/2009/07/06/online-php-mysql-crud-scaffold-generator/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 18:08:39 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Web developmnet]]></category>
		<category><![CDATA[CRUD]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[scaffold]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/?p=506</guid>
		<description><![CDATA[I needed some simple PHP MySQL CRUD and found www.phpscaffold.com. Perfect!
]]></description>
			<content:encoded><![CDATA[<p>I needed some simple PHP MySQL CRUD and found <a href="http://www.phpscaffold.com/" onclick="pageTracker._trackPageview('/outgoing/www.phpscaffold.com/?referer=');">www.phpscaffold.com</a>. Perfect!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2009/07/06/online-php-mysql-crud-scaffold-generator/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Permute an array in PHP</title>
		<link>http://www.divideandconquer.se/2009/06/04/permute-an-array-in-php/</link>
		<comments>http://www.divideandconquer.se/2009/06/04/permute-an-array-in-php/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 08:20:53 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[permutate]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/?p=456</guid>
		<description><![CDATA[I wrote this function recently when I could not find it in the PHP function list. Please provide any optimizations you discover!
function permute($array)
{
  $results = array();

  if (count($array) == 1)
  {
    $results[] = $array;
  }
  else
  {
    for ($i = 0; $i &#60; [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote this function recently when I could not find it in the PHP function list. Please provide any optimizations you discover!</p>
<pre>function permute($array)
{
  $results = array();

  if (count($array) == 1)
  {
    $results[] = $array;
  }
  else
  {
    for ($i = 0; $i &lt; count($array); $i++)
    {
      $first = array_shift($array);
      $subresults = permute($array);
      array_push($array, $first);
      foreach ($subresults as $subresult)
      {
        $results[] = array_merge(array($first), $subresult);
      }
    }
  }
  return $results;
}

assert(permute(array()) == array());
assert(permute(array(1)) == array(array(1)));
assert(permute(array(1,2)) == array(array(1,2),array(2,1)) ||
       permute(array(1,2)) == array(array(2,1),array(1,2)));
assert(count(permute(array(1,2,3)) == 6));
assert(count(permute(array(1,2,3,4)) == 24));</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2009/06/04/permute-an-array-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Namespace separator in PHP</title>
		<link>http://www.divideandconquer.se/2008/10/27/namespace-separator-in-php/</link>
		<comments>http://www.divideandconquer.se/2008/10/27/namespace-separator-in-php/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 20:25:26 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/2008/10/27/namespace-separator-in-php/</guid>
		<description><![CDATA[Danne has the stuff, but I can tell that backslash is the buzz!
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dotvoid.com/2008/10/finally-namespaces/" target="_self" onclick="pageTracker._trackPageview('/outgoing/www.dotvoid.com/2008/10/finally-namespaces/?referer=');">Danne has the stuff</a>, but I can tell that backslash is the buzz!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2008/10/27/namespace-separator-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress crack attempt this morning!</title>
		<link>http://www.divideandconquer.se/2008/04/16/wordpress-crack-attempt-this-morning/</link>
		<comments>http://www.divideandconquer.se/2008/04/16/wordpress-crack-attempt-this-morning/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 08:12:50 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Meta]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[WWW]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/2008/04/16/wordpress-crack-attempt-this-morning/</guid>
		<description><![CDATA[When I got to work and viewed this blog I noticed that Sidebar Widgets was disabled. I thought &#34;That&#8217;s weird!&#34;
When I tried to login to the administration interface I was told that my WordPress database needed upgrading. I thought &#34;That&#8217;s weird!&#34;
Some further investigation revealed that someone managed to upload a PHP script called ro8kfbsmag.txt (MD5 [...]]]></description>
			<content:encoded><![CDATA[<p>When I got to work and viewed this blog I noticed that <a href="http://svn.wp-plugins.org/widgets/trunk" title="Visit plugin homepage" onclick="pageTracker._trackPageview('/outgoing/svn.wp-plugins.org/widgets/trunk?referer=');">Sidebar Widgets</a> was disabled. I thought &quot;That&#8217;s weird!&quot;</p>
<p>When I tried to login to the administration interface I was told that my WordPress database needed upgrading. I thought &quot;That&#8217;s weird!&quot;</p>
<p>Some further investigation revealed that someone managed to upload a PHP script called ro8kfbsmag.txt (MD5 sum df3b74cd38c717d9d7bbf0cd1910baa1) to my /tmp directory. It starts like this:</p>
<p style="margin-left: 40px;"><code>&lt;?php<br />
/*Magic Include Shell by Mag icq 884888*/<br />
//TODO: &ntilde;&euml;&egrave;&ograve;&uuml; &ocirc;&agrave;&eacute;&euml;&icirc; &iacute;&agrave; &ntilde;&acirc;&icirc;&eacute; &ocirc;&ograve;&iuml; (!)<br />
$ver='2.1';<br />
if(isset($_GET[pisun233]))<br />
{</code></p>
<p>This gave me enough information too start googling. A must-read is <a href="http://blog.taragana.com/index.php/archive/detailed-post-mortem-of-a-website-hack-through-wordpress-how-to-protect-your-wordpress-blog-from-hacking/" rel="bookmark" title="Detailed Post-Mortem of a Website Hack Through WordPress &amp; How To Protect Your WordPress Blog From Hacking" onclick="pageTracker._trackPageview('/outgoing/blog.taragana.com/index.php/archive/detailed-post-mortem-of-a-website-hack-through-wordpress-how-to-protect-your-wordpress-blog-from-hacking/?referer=');"> Detailed Post-Mortem of a Website Hack Through WordPress &amp; How To Protect Your WordPress Blog From Hacking</a>, as it describes a very similar attack. There is also a support thread at wordpress.org: <a href="http://wordpress.org/support/topic/141041" target="_self" onclick="pageTracker._trackPageview('/outgoing/wordpress.org/support/topic/141041?referer=');">Weird and Dangerous : ro8kfbsmag.txt</a>.</p>
<p>The attack vector on my server looked like this, originating from 78.109.21.80 with HTTP/1.0 as protocol version and &quot;Opera&quot; as User-Agent. I wish I logged POST data!</p>
<p style="margin-left: 40px;">POST /wp-admin/options.php<br />
POST /wp-admin/upload.php<br />
POST /wp-admin/options.php<br />
POST /wp-admin/options.php<br />
POST /wp-admin/inline-uploading.php?post=-1&amp;action=upload<br />
POST /wp-admin/options.php<br />
POST /wp-admin/options.php<br />
POST /wp-admin/upload.php?style=inline&amp;tab=upload&amp;post_id=-1<br />
POST /wp-admin/upload.php?style=inline&amp;tab=upload&amp;post_id=-1<br />
POST /wp-admin/options.php<br />
POST /wp-admin/options.php<br />
GET /wp-admin/upgrade.php?step=1</p>
<p>Needless to say, I have restored a backup and taken certain precautions to prevent this from happening again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2008/04/16/wordpress-crack-attempt-this-morning/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Andi Gutmans: &#8220;Java is losing the battle for the modern Web&#8221;</title>
		<link>http://www.divideandconquer.se/2008/03/28/andi-gutmans-java-is-losing-the-battle-for-the-modern-web/</link>
		<comments>http://www.divideandconquer.se/2008/03/28/andi-gutmans-java-is-losing-the-battle-for-the-modern-web/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 18:23:59 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WWW]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/2008/03/28/andi-gutmans-java-is-losing-the-battle-for-the-modern-web/</guid>
		<description><![CDATA[Andi Gutmans (of PHP fame) has written a very interesting blog post about Java&#8217;s future on the web. The article is called  Java is losing the battle for the modern Web. Can the JVM save the vendors? He gives some good arguments for using a LAMP stack for web applications.
One of the interesting quotes [...]]]></description>
			<content:encoded><![CDATA[<p>Andi Gutmans (of PHP fame) has written a very interesting blog post about Java&#8217;s future on the web. The article is called  <a target="_self" href="http://andigutmans.blogspot.com/2008/03/java-is-losing-battle-for-modern-web.html" onclick="pageTracker._trackPageview('/outgoing/andigutmans.blogspot.com/2008/03/java-is-losing-battle-for-modern-web.html?referer=');">Java is losing the battle for the modern Web. Can the JVM save the vendors?</a> He gives some good arguments for using a LAMP stack for web applications.</p>
<p>One of the interesting quotes is:</p>
<blockquote>
<p>Project Zero&rsquo;s Chief Architect is one of the first IBMers to admit in public that Java today can be considered as a system language and is not desirable for building RESTful Web applications [...]<i><br />
</i></p>
</blockquote>
<p>This was apparently a bit out of context, according to the <a href="http://andigutmans.blogspot.com/2008/03/java-is-losing-battle-for-modern-web.html#c6659178041135325354" target="_self" onclick="pageTracker._trackPageview('/outgoing/andigutmans.blogspot.com/2008/03/java-is-losing-battle-for-modern-web.html_c6659178041135325354?referer=');">comment by Jason McGee</a>, but fun to read nevertheless.</p>
<p>He makes a prediction that shall be interesting to see if comes true:</p>
<blockquote>
<p>It has taken over 10 years for the Java stronghold to admit Java&rsquo;s poor ROI on the Web and with the current recession it is likely that many Java customers are going to be making more informed investments. As a result there will be considerable rise in uptake of dynamic languages.</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2008/03/28/andi-gutmans-java-is-losing-the-battle-for-the-modern-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL support for UTF-8 in PHP</title>
		<link>http://www.divideandconquer.se/2007/12/10/mysql-support-for-utf-8-in-php/</link>
		<comments>http://www.divideandconquer.se/2007/12/10/mysql-support-for-utf-8-in-php/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 12:30:19 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/2007/12/10/mysql-support-for-utf-8-in-php/</guid>
		<description><![CDATA[Originally published in Swedish in my Folkmun.se Blog, a handy tip to make sure that you are reading and writing UTF-8 when connecting to a MySQL database:
mysql_query("SET NAMES utf8");
mysql_query("SET CHARACTER SET utf8")
]]></description>
			<content:encoded><![CDATA[<p>Originally published in Swedish in my <a href="http://blogg.folkmun.se/2007/05/05/mysql-och-utf-8-i-php/" onclick="pageTracker._trackPageview('/outgoing/blogg.folkmun.se/2007/05/05/mysql-och-utf-8-i-php/?referer=');">Folkmun.se Blog</a>, a handy tip to make sure that you are reading and writing UTF-8 when connecting to a MySQL database:</p>
<pre>mysql_query("SET NAMES utf8");
mysql_query("SET CHARACTER SET utf8")</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2007/12/10/mysql-support-for-utf-8-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
