<?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>alexander kirk &#187; php</title>
	<atom:link href="http://alexander.kirk.at/category/code/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://alexander.kirk.at</link>
	<description></description>
	<lastBuildDate>Thu, 22 Jul 2010 15:11:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Debugging PHP on Mac OS X</title>
		<link>http://alexander.kirk.at/2008/12/26/debugging-php-on-mac-os-x/</link>
		<comments>http://alexander.kirk.at/2008/12/26/debugging-php-on-mac-os-x/#comments</comments>
		<pubDate>Fri, 26 Dec 2008 18:18:15 +0000</pubDate>
		<dc:creator>Alexander Kirk</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://alexander.kirk.at/?p=104</guid>
		<description><![CDATA[I have been using Mac OS X as my primary operating system for a few years now, and only today I have found a very neat way to debug PHP code, like it is common for application code (i.e. stepping through code for debugging purposes). The solution is a combination of Xdebug and MacGDBp. I [...]]]></description>
			<content:encoded><![CDATA[<div class="factolex-glossary"><div class="factolex-glossary-header"><a href="http://en.factolex.com/">Glossary powered by Factolex.com</a></div><div class="factolex-glossary-content"><h2><a href="http://en.factolex.com/Operating_system:system">Operating system</a></h2><ul><li>the software component of a computer system that is responsible for the management and coordination of activities and the sharing of the resources of the computer</li></ul><h2><a href="http://en.factolex.com/OS_X">OS X</a></h2><ul><li>a line of computer operating systems developed, marketed, and sold by Apple Inc, the latest of which is pre-loaded on all currently shipping Macintosh computers</li></ul><h2><a href="http://en.factolex.com/PHP:computer">PHP</a></h2><ul><li>an open source programming language</li></ul></div></div>
<p>I have been using Mac OS X as my primary operating system for a few years now, and only today I have found a very neat way to debug PHP code, like it is common for application code (i.e. stepping through code for debugging purposes).</p>
<p>The solution is a combination of <a href="http://www.xdebug.org/">Xdebug</a> and <a href="http://www.bluestatic.org/software/macgdbp/">MacGDBp</a>.</p>
<p><img src="http://alexander.kirk.at/wp-content/uploads/2008/12/macgdbp-debugger-300x227.png" alt="macgdbp-debugger" title="macgdbp-debugger" width="300" height="227" class="aligncenter size-medium wp-image-105" /></p>
<p>I am using the PHP package by <a href="http://www.entropy.ch/software/macosx/php/">Marc Liyanage</a> almost ever since I have been working on OS X, because it&#039;s far more flexible than the PHP shipped with OS X.</p>
<p>Unfortunately, installing Xdebug the usual <tt>pecl install xdebug</tt> doesn&#039;t work. But on the internetz you can find a <a href="http://www.designified.com/blog/article/60/compiling-installing-xdebug-for-php-525-entropych-build-on-os-x-105">solution to this problem</a>.</p>
<p>Basically you need to download the source tarball and use the magic command <tt>CFLAGS='-arch x86_64' ./configure --enable-xdebug</tt> for configuring it. (The same works for installing APC by the way)</p>
<p><code><br />
/usr/local/php5/php.d $ cat 50-extension-xdebug.ini<br />
[xdebug]<br />
zend_extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so</p>
<p>xdebug.remote_autostart=on<br />
xdebug.remote_enable=on<br />
xdebug.remote_handler=dbgp<br />
xdebug.remote_mode=req<br />
xdebug.remote_host=localhost<br />
xdebug.remote_port=9000<br />
</code></p>
<p>Now you can use MacGDBp. There is an <a href="http://particletree.com/notebook/silence-the-echo-with-macgdbp/">article on Particletree</a> that describes the interface in a little more detail.</p>
<p>I really enjoy using this method to only fire up this external program, when I want to debug some PHP code, and can continue to use my small editor, so that I don&#039;t have to switch to a huge IDE to accomplish the same.</p>
]]></content:encoded>
			<wfw:commentRss>http://alexander.kirk.at/2008/12/26/debugging-php-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse Everywhere. Buah.</title>
		<link>http://alexander.kirk.at/2005/10/19/eclipse-everywhere-buah/</link>
		<comments>http://alexander.kirk.at/2005/10/19/eclipse-everywhere-buah/#comments</comments>
		<pubDate>Wed, 19 Oct 2005 10:02:44 +0000</pubDate>
		<dc:creator>Alexander Kirk</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://alexander.kirk.at/?p=31</guid>
		<description><![CDATA[It&#039;s been a little quiet lately. This is because I am working on a cute little project that I will be able to present soon. More when the time is ready. There has been rumor lately that Zend (developer of PHP) will release a PHP Framework. This is nothing new, there has been a IDE [...]]]></description>
			<content:encoded><![CDATA[<p>It&#039;s been a little quiet lately. This is because I am working on a cute little project that I will be able to present soon. More when the time is ready.</p>
<p>There has been rumor lately that Zend (developer of PHP) will release a <a href="http://www.procata.com/blog/archives/2005/10/17/zend-php-framework/">PHP Framework</a>. This is nothing new, there has been a IDE (<a href="http://www.zend.com/store/products/zend-studio/">Zend </a>) for a long time now. But it will be based on <a href="http://www.eclipse.org/">Eclipse</a>.</p>
<p>Also Macromedia announced that their new <a href="http://www.macromedia.com/software/flex/">Flex 2.0</a> environment (Flashbuilder) will be based on Eclispe.</p>
<p>Why on earth Eclipse?! I think this is the most slowest IDEs available. It&#039;s based on Java which makes it incredibly slow already and it&#039;s so blown up that it&#039;s unbelievable.</p>
<p>I just can&#039;t understand why developers would use such a tool. I am not willing to buy a GHz monster PC just to have an editor running there. That&#039;s a pure waste of money and electricity. Emacs is kinda slow already but it runs on a few MHz.</p>
<p>Can anyone explain to me why to use such a monster? </p>
<p>I thought that maybe everything changed for the better by now and downloaded the whole thing. That&#039;s 100MB already. This already shows how much memory it will consume. Ok, I still started it. It took more than 2 minutes on my Powerbook G4. Hello? The features it provides are so not worth that.</p>
<p>I can recommend <a href="http://www.textmate.com/">TextMate</a> (best completition) and <a href="http://www.editplus.com/">EditPlus</a> (best integrated (S)FTP). These are fast, neat text editors. That&#039;s what I want.</p>
<p><a href="http://technorati.com/tag/eclipse" rel="tag">eclipse</a>, <a href="http://technorati.com/tag/zend" rel="tag"> zend</a>, <a href="http://technorati.com/tag/php" rel="tag"> php</a>, <a href="http://technorati.com/tag/flex" rel="tag"> flex</a>, <a href="http://technorati.com/tag/textmate" rel="tag"> textmate</a>, <a href="http://technorati.com/tag/editplus" rel="tag"> editplus</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alexander.kirk.at/2005/10/19/eclipse-everywhere-buah/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Better code downloading with AJAX</title>
		<link>http://alexander.kirk.at/2005/10/10/better-code-downloading-with-ajax/</link>
		<comments>http://alexander.kirk.at/2005/10/10/better-code-downloading-with-ajax/#comments</comments>
		<pubDate>Mon, 10 Oct 2005 17:39:18 +0000</pubDate>
		<dc:creator>Alexander Kirk</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://alexander.kirk.at/?p=28</guid>
		<description><![CDATA[I&#039;ve been playing with Code downloading (or Javascript on Demand) a little more. Michael Mahemoff pointed me at his great Ajaxpatterns in which he suggests a different solution: if (self.uploadMessages) { // Already exists &#160;&#160;return; } var head = document.getElementsByTagName("head")[0]; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = "upload.js"; head.appendChild(script); Via DOM manipulation a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#039;ve been playing with Code downloading (or Javascript on Demand) a little more.</p>
<p><a href="http://www.softwareas.com/ajax-can-improve-performance-too">Michael Mahemoff</a> pointed me at his great <a href="http://www.ajaxpatterns.org/">Ajaxpatterns</a> in which he suggests a <a href="http://ajaxpatterns.org/On-Demand_Javascript">different solution</a>:<br />
<code><br />
if (self.uploadMessages) { // Already exists<br />
&nbsp;&nbsp;return;<br />
}<br />
var head = document.getElementsByTagName("head")[0];<br />
var script = document.createElement('script');<br />
script.type = 'text/javascript';<br />
script.src = "upload.js";<br />
head.appendChild(script);<br />
</code></p>
<p>Via DOM manipulation a new script tag is added to our document, loading the new script via the &#039;src&#039; attribute. I have put <a href="http://alexander.kirk.at/area7/2005/10/10/">a working example here</a>. As you can see this does not even need to do an XmlHttpRequest (XHR later on) so it will also work on browsers not supporting that.</p>
<p>So why use this approach and not mine? Initially I thought that it was not as good as doing it via XHR because you receive a direct feedback (i.e. a function call) when the script has been loaded. This is per se not possible with this technique. But as in good ol&#039; times a simple function call at the end of the script file will do the same job (compare source codes from <a href="http://alexander.kirk.at/area7/2005/10/05/">the last example</a> and <a href="http://alexander.kirk.at/area7/2005/10/10/">this one</a> (plus <a href="http://alexander.kirk.at/area7/2005/10/10/load.js">load.js</a>)).</p>
<p>Using this method to load code later on also provides another &#034;feature&#034; (thanks for that hint to <a href="http://erik.eae.net/">Erik Arvidsson</a>): Unlike XHRs Firefox also provides a cache for scripts loaded that way. There seems to be a disagreement about whether this is a bug or a feature (people complaining that IE caches such requests while it could be quite useful in this scenario).</p>
<p>When using dynamically generated javascript code you will also have to keep your HTTP headers in mind (scripts don&#039;t send them by default). The headers <code>Cache-Control</code> and <code>Last-Modified</code> will do usually (see <a href="http://alexander.kirk.at/papers/caching-strategies/diploma_thesisch6.html#x17-730006.1.2">section 6.1.2 of my thesis</a>)</p>
<p>The method above is also the method used by <a href="http://www.dojotoolkit.org/">Dojo</a>, a developer (<a href="http://stilleye.com/">David Schontzler</a>) commented, too. He says that Dojo also only loads the stuff the programmer needs, so little overhead can be expected from this project.</p>
<p>Also <a href="http://alex.dojotoolkit.org/">Alex Russell</a> from Dojo left a comment about <a href="http://alexander.kirk.at/2005/10/03/bloated-ajax-applications-due-to-libraries/">bloated javascript libraries</a>. He has some good points about script size to say (<a href="http://alexander.kirk.at/2005/10/03/bloated-ajax-applications-due-to-libraries/#comments">read for yourself</a>), I just want quote the best point of his posting:</p>
<p><cite>So yes, large libraries are a problem, but developers need some of the capabilities they provide. The best libraries, though, should make you only pay for what you use. Hopefully Dojo and JSAN will make this the defacto way of doing things.</cite></p>
<p>So hang on for Dojo, they seem to be on a good way (coverage of Dojo to follow).</p>
<p>Finally I want to thank you all for your great and insightful comments!</p>
<p><a href="http://technorati.com/tag/ajax" rel="tag">ajax</a>, <a href="http://technorati.com/tag/dojo" rel="tag"> dojo</a>, <a href="http://technorati.com/tag/code+downloading" rel="tag"> code downloading</a>, <a href="http://technorati.com/tag/javascript+on+demand" rel="tag"> javascript on demand</a>, <a href="http://technorati.com/tag/caching" rel="tag"> caching</a>, <a href="http://technorati.com/tag/http+headers" rel="tag"> http headers</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alexander.kirk.at/2005/10/10/better-code-downloading-with-ajax/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP and Multibyte</title>
		<link>http://alexander.kirk.at/2005/04/05/php-and-multibyte/</link>
		<comments>http://alexander.kirk.at/2005/04/05/php-and-multibyte/#comments</comments>
		<pubDate>Mon, 04 Apr 2005 23:58:01 +0000</pubDate>
		<dc:creator>Alexander Kirk</dc:creator>
				<category><![CDATA[bandnews]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://alex.bandnews.org/?p=11</guid>
		<description><![CDATA[ever messed around with umlauts or other non [a-z] letters? it&#039;s quite horrible. for the german speaking region there are mainly two encoding types: iso8859-1 and utf-8. the former encodes each letter with one byte by extending old 7-bit ascii with 127 more letters, amongst others also umlauts. utf-8 includes up to 32,640 more&#160;&#160;letters (ascii [...]]]></description>
			<content:encoded><![CDATA[<p>ever messed around with umlauts or other non [a-z] letters? it&#039;s quite horrible.</p>
<p>for the german speaking region there are mainly two encoding types: iso8859-1 and utf-8. the former encodes each letter with one byte by extending old 7-bit ascii with 127 more letters, amongst others also umlauts. utf-8 includes up to 32,640 more&nbsp;&nbsp;letters (ascii 0&#215;80-0xff are used to select the range of the following byte). this is established by allowing multi-byte characters. in the case of utf-8 the maximum is two letters, but there exist utf-16 and utf-32 with up to 4 bytes per char.</p>
<p>so, what&#039;s the problem? with bandnews we have different sources for our data, meaning that we receive many pages with many different encodings and have to deliver a page that follows only one encoding. we chose to use utf-8 now, because a wide range of letters from many other encodings can be displayed which are not included in iso8859-1.</p>
<p>now it is important that you stop using <a href="http://php.net/strlen">strlen</a> and <a href="http://php.net/substr">substr</a> because it can easily happen that you split an utf-8 character into parts, and forget comparing it to anything, then. alterenatives are <a href="http://php.net/mb_strlen">mb_strlen</a> and <a href="http://php.net/mb_substr">mb_substr</a> and all other sorts of <a href="http://php.net/manual/en/ref.mbstring.php">mb_*</a> functions. well&#8230; this does not work out of the box, you need to specify what encoding is to be expected. this can be done like this:<br />
<code><br />
mb_internal_encoding("UTF-8");<br />
</code><br />
all mb_* commands use this encoding if no other is specified.</p>
<p>still, non-utf-8 code can come through to the browser, e.g. if you receive it from the database. but there is a chance to get around this quite comfortably:<br />
<code><br />
mb_http_output("UTF-8");<br />
ob_start("mb_output_handler");<br />
</code><br />
the output buffer is cleared from wrong charactes by the mb_output_handler. it is also easily possible to have the output converted to iso8859-1, just by specifying it with the <a href="http://php.net/mb_http_output">mb_http_output</a> command.<br />
a drawback is, though, that no other output filter can be applied, such as for output compression<br />
<code><br />
ob_start("ob_gzhandler");<br />
</code></p>
<p>the manual states that instead zlib compression should be used, as specified in the php.ini file or via <a href="http://php.net/ini_set">ini_set</a>:<br />
<code><br />
ini_set ('zlib.output_compression', 'on');<br />
ini_set ('zlib.output_handler', 'mb_output_handler');<br />
ob_start();<br />
</code><br />
note that the output-handler for <a href="http://php.net/ob_start">ob_start</a> has to be empty and it is moved to the config option. this sounds great, but i was not able to get it to work. well, i must admit that i did not put so much time into it because i simply decided to move the responsibility to apache: <a href="http://httpd.apache.org/docs-2.0/mod/mod_deflate.html">mod_deflate</a>. you might want to modify the configuration line, as i did:<br />
<code><br />
 AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css<br />
</code></p>
<p>have fun with character encoding. it works after some while. but its a lot of trial and error.</p>
]]></content:encoded>
			<wfw:commentRss>http://alexander.kirk.at/2005/04/05/php-and-multibyte/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
