<?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"
	>

<channel>
	<title>Developer Tutorials' Webmaster Blog</title>
	<atom:link href="http://developertutorials.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.developertutorials.com/blog</link>
	<description>Keeping webmasters up-to-date on technology.</description>
	<pubDate>Tue, 02 Sep 2008 14:59:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>Styling Disabled Buttons / Disabled Text Boxes in CSS</title>
		<link>http://www.developertutorials.com/blog/web/styling-disabled-buttons-disabled-text-boxes-in-css-404/</link>
		<comments>http://www.developertutorials.com/blog/web/styling-disabled-buttons-disabled-text-boxes-in-css-404/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 11:08:23 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/web/styling-disabled-buttons-disabled-text-boxes-in-css-404/</guid>
		<description><![CDATA[As your forms grow in complexity, you&#8217;ll probably find a need to temporarily disable an input - either a button, a text box, or some other element. This is quite easy in HTML - the disabled attribute comes to the rescue. But just how do you style those fields, and convey that they are temporarily [...]]]></description>
			<content:encoded><![CDATA[<p>As your forms grow in complexity, you&#8217;ll probably find a need to temporarily disable an input - either a button, a text box, or some other element. This is quite easy in HTML - the disabled attribute comes to the rescue. But just how do you style those fields, and convey that they are temporarily disabled?</p>
<p><span id="more-404"></span></p>
<p>Let&#8217;s consider this standard input field:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;text&quot; value=&quot;Text.&quot; disabled /&gt;</pre></div></div>

<input type="text" value="Text." disabled />
<p>Pretty standard stuff. Your web browser will automatically style it a little, but mostly just prevent the user from editing without any real visual hints. But let&#8217;s add some basic CSS to convey the state of the input, and to standardise it across our site and on most platforms. If we add the following CSS:</p>

<div class="wp_syntax"><div class="code"><pre class="css css" style="font-family:monospace;">input<span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#999</span>;
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ddd</span>;
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<input type="text" value="Text." disabled style="border:1px solid #999;background-color:#ddd" />
<p>But wait - our demo uses inline styles, but your browser might not have just styled that properly if we used a full CSS declaration. We don&#8217;t set a value for the disabled attribute - it&#8217;s a <em>minimized</em> attribute. To get IE to play nicely with it (and for XHTML), we&#8217;ll have to set the value to &#8220;disabled&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;text&quot; value=&quot;Text.&quot; disabled=&quot;disabled&quot; /&gt;</pre></div></div>

<p>If possible, just for total compatibility, we can also add a &#8220;disabled&#8221; class that IE6 will respect and apply styles for correctly.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;text&quot; value=&quot;Text.&quot; disabled=&quot;disabled&quot; class=&quot;disabled&quot; /&gt;</pre></div></div>

<p>We can then change the CSS selector we&#8217;re using:</p>

<div class="wp_syntax"><div class="code"><pre class="css css" style="font-family:monospace;">input<span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;disabled&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">,</span> input.disabled</pre></div></div>

<p>And we&#8217;re done! This works across every major browser - IE6+ and FF1.0+ tested, and Safari 3 / Opera 9.5 should be fine as well. The Sitepoint CSS reference has further information on compatibility, <a href="http://reference.sitepoint.com/css/attributeselector#compatibilitysection" target="_blank">available here</a>.</p>
<p>Finally, if you want to see how Firefox styles disabled fields by default, load up your resource://gre/res/forms.css file (you&#8217;ll have to copy and paste it to your address bar). There are a number of lengthy selectors with just a few rules, but here&#8217;s the big one, way down the bottom:</p>

<div class="wp_syntax"><div class="code"><pre class="css css" style="font-family:monospace;">button<span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span><span style="color: #3333ff;">:active</span><span style="color: #00AA00;">,</span> button<span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">,</span>
input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;reset&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span><span style="color: #3333ff;">:active</span><span style="color: #00AA00;">,</span>
input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;reset&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">,</span>
input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;button&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span><span style="color: #3333ff;">:active</span><span style="color: #00AA00;">,</span>
input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;button&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">,</span>
select<span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&gt;</span> input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;button&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">,</span>
select<span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&gt;</span> input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;button&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #3333ff;">:active</span><span style="color: #00AA00;">,</span>
input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span><span style="color: #3333ff;">:active</span><span style="color: #00AA00;">,</span>
input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&#91;</span>disabled<span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">6px</span> <span style="color: #933;">0px</span> <span style="color: #933;">6px</span>;
  <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #993333;">outset</span> ButtonFace;
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> GrayText;
  <span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inherit</span>;
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>GrayText is actually a system color - it&#8217;s defined by the CSS 2.1 specification and supported on and off in various browsers. These &#8220;special&#8221; color keywords are supposed to match the local system styles - on a Windows machine, for instance, Firefox would use the color: GrayText rule to style text in disabled fields with the same color that the local Windows system uses. A list of options is available on the <a href="http://reference.sitepoint.com/css/colorvalues">CSS reference</a> as well.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark" style="float:left;">
<div class="d404" style="overflow:hidden">
<div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/web/styling-disabled-buttons-disabled-text-boxes-in-css-404/&amp;title=Styling+Disabled+Buttons+%2F+Disabled+Text+Boxes+in+CSS" title="Add to&nbsp;Del.icio.us">Del.icio.us</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/web/styling-disabled-buttons-disabled-text-boxes-in-css-404/&amp;title=Styling+Disabled+Buttons+%2F+Disabled+Text+Boxes+in+CSS" title="Add to&nbsp;Digg This">Digg This</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/web/styling-disabled-buttons-disabled-text-boxes-in-css-404/&amp;title=Styling+Disabled+Buttons+%2F+Disabled+Text+Boxes+in+CSS" title="Add to&nbsp;Stumble">Stumble</a></div></div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/web/styling-disabled-buttons-disabled-text-boxes-in-css-404/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Easy Screen Scraping in PHP with the Simple HTML DOM Library</title>
		<link>http://www.developertutorials.com/blog/php/easy-screen-scraping-in-php-simple-html-dom-library-simplehtmldom-398/</link>
		<comments>http://www.developertutorials.com/blog/php/easy-screen-scraping-in-php-simple-html-dom-library-simplehtmldom-398/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 07:10:54 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/easy-screen-scraping-in-php-simple-html-dom-library-simplehtmldom-398/</guid>
		<description><![CDATA[Client-side developers always had it easy - libraries such as jQuery and Prototype make finding elements on the page reliable and efficient. In PHP, regular expressions tend to get rather messy, DOM calls can be confusing and verbose, and often the string functions just aren&#8217;t enough. In this tutorial, I&#8217;ll show you how to use [...]]]></description>
			<content:encoded><![CDATA[<p>Client-side developers always had it easy - libraries such as jQuery and Prototype make finding elements on the page reliable and efficient. In PHP, regular expressions tend to get rather messy, DOM calls can be confusing and verbose, and often the string functions just aren&#8217;t enough. In this tutorial, I&#8217;ll show you how to use the middle ground - the open source PHP Simple HTML DOM Parser library, which provides jQuery-grade awesomeness for easy screen scraping without messy regular expressions.<span id="more-398"></span></p>
<p>The <a href="http://simplehtmldom.sourceforge.net/">Simple HTML DOM Parser</a> is implemented as a simple PHP class and a few helper functions. It supports CSS selector style screen scraping (such as in jQuery), can handle invalid HTML, and even provides a familiar interface to manipulate a DOM.</p>
<p>Here&#8217;s a sample of simplehtmldom in action:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> file_get_dom<span style="color: #009900;">&#40;</span><span style="">'http://www.google.com/'</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="">'a'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$element</span><span style="color: #009900;">&#41;</span>
    <span style="color: #990000;">echo</span> <span style="color: #000088;">$element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">href</span>;</pre></div></div>

<p>This snippet is fairly self explanatory - <code>file_get_dom()</code> is a simple helper function in the library that fetches the page and constructs a new simplehtmldom object around it. Once the object is available, we can easily use simple CSS selectors to find our elements - in this case, anchors - and iterate over them just as we would with PHP 5&#8217;s standard DOM classes. (The equivalent code with the standard DOM classes is twice as long.)</p>
<p>But the library doesn&#8217;t stop there - as well as traversing the DOM and extracting information, you can also alter it. Consider this snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> str_get_html<span style="color: #009900;">&#40;</span><span style="">'
&lt;div id=&quot;hello&quot;&gt;Hello&lt;/div&gt;
&lt;div id=&quot;world&quot;&gt;World&lt;/div&gt;
&nbsp;
'</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="">'div'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">class</span> <span style="color: #339933;">=</span> <span style="">'bar'</span>;
&nbsp;
<span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="">'div[id=hello]'</span><span style="color: #339933;">,</span> <span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">innertext</span> <span style="color: #339933;">=</span> <span style="">'foo'</span>;</pre></div></div>

<p>The library supports many DOM-style approaches for manipulation, from exposing real attributes as shown here, to a few helper methods. It also includes other methods to traverse the current node - <code>children()</code>, <code>parent()</code>, <code>first_child()</code> and so on.</p>
<p>Real scraping? Easy. Here&#8217;s their Slashdot sample:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> file_get_html<span style="color: #009900;">&#40;</span><span style="">'http://slashdot.org/'</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="">'div.article'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$article</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="">'title'</span><span style="color: #009900;">&#93;</span>     <span style="color: #339933;">=</span> <span style="color: #000088;">$article</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="">'div.title'</span><span style="color: #339933;">,</span> <span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">plaintext</span>;
    <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="">'intro'</span><span style="color: #009900;">&#93;</span>    <span style="color: #339933;">=</span> <span style="color: #000088;">$article</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="">'div.intro'</span><span style="color: #339933;">,</span> <span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">plaintext</span>;
    <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="">'details'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$article</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="">'div.details'</span><span style="color: #339933;">,</span> <span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">plaintext</span>;
    <span style="color: #000088;">$articles</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$articles</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>And finally, there&#8217;s always a simple save mechanism:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="">'altered-dom.html'</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>Ready to get started? Head over to the <a href="http://simplehtmldom.sourceforge.net/">project website</a>, <a href="http://simplehtmldom.sourceforge.net/manual.htm">online documentation</a> or the <a href="https://sourceforge.net/projects/simplehtmldom/">project page on SourceForge</a>.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark" style="float:left;">
<div class="d398" style="overflow:hidden">
<div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/easy-screen-scraping-in-php-simple-html-dom-library-simplehtmldom-398/&amp;title=Easy+Screen+Scraping+in+PHP+with+the+Simple+HTML+DOM+Library" title="Add to&nbsp;Del.icio.us">Del.icio.us</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/easy-screen-scraping-in-php-simple-html-dom-library-simplehtmldom-398/&amp;title=Easy+Screen+Scraping+in+PHP+with+the+Simple+HTML+DOM+Library" title="Add to&nbsp;Digg This">Digg This</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/easy-screen-scraping-in-php-simple-html-dom-library-simplehtmldom-398/&amp;title=Easy+Screen+Scraping+in+PHP+with+the+Simple+HTML+DOM+Library" title="Add to&nbsp;Stumble">Stumble</a></div></div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/easy-screen-scraping-in-php-simple-html-dom-library-simplehtmldom-398/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Four CSS Tricks Every PHP / Web Developer Should Know</title>
		<link>http://www.developertutorials.com/blog/php/four-css-tricks-every-php-web-developer-should-know-391/</link>
		<comments>http://www.developertutorials.com/blog/php/four-css-tricks-every-php-web-developer-should-know-391/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 05:00:27 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/four-css-tricks-every-php-web-developer-should-know-391/</guid>
		<description><![CDATA[It&#8217;s not easy being a web developer - in addition to a server-side language, we also have to learn a markup language, yet another (client-side) language and a presentation system. As a result, we tend to focus on what we&#8217;re closest to - the business logic - and neglect the front-end.
But you don&#8217;t have to [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s not easy being a web developer - in addition to a server-side language, we also have to learn a markup language, yet another (client-side) language and a presentation system. As a result, we tend to focus on what we&#8217;re closest to - the business logic - and neglect the front-end.</p>
<p>But you don&#8217;t have to be a web dev guru to build great applications: with just a few simple tricks, you can make your web based interfaces more usable and more visually appealing. Here are a few simple CSS tricks every PHP / web developer should know.<span id="more-391"></span></p>
<p>Here&#8217;s a quick preview of how we&#8217;re going to transform our page:</p>
<p><img src="http://www.developertutorials.com/blog/wp-content/uploads/2008/07/css-1.png" alt="" title="CSS Before" width="166" height="166" class="alignnone size-full wp-image-389" /> <img src="http://www.developertutorials.com/blog/wp-content/uploads/2008/07/css-2.png" alt="" title="CSS After" width="166" height="166" class="alignnone size-full wp-image-390" /></p>
<p><strong>1. Styling Form Inputs, Buttons</strong><br />
When you pop an &lt;input&gt; onto your page, it&#8217;s at the mercy of the end user&#8217;s system for appearance, behaviour - even size. For example, Firefox handles unstyled inputs differently from IE, and both take many cues from the local OS styling; the same goes for Safari. This is okay on modern OSes &#8212; if you aren&#8217;t concerned with controlling your visuals &#8212; but quite a few users still run &#8220;Classic&#8221; interfaces, and it&#8217;s especially annoying for buttons. Here are some basic styles you should consider for your inputs.</p>

<div class="wp_syntax"><div class="code"><pre class="css css" style="font-family:monospace;">input <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span>;
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#F0F0F0</span>;
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>These will first add a bit of padding to your text boxes and buttons, and set in stone your border color to a soft gray. In particular, most browsers will render a clean rectangular button with this style present. Consider defining a width in pixels or percents (if inside a container) as well.</p>
<p><strong>2. Styling Tables</strong><br />
Remember to style tables nicely, with table row hover colors, reasonable borders and maybe even striped tables. After all, tables can be dull and boring:</p>
<table border="1">
<tr>
<th>Heading 1</th>
<th>Heading 2</th>
</tr>
<tr>
<td>Value</td>
<td>Value</td>
</tr>
<tr>
<td>Value</td>
<td>Value</td>
</tr>
</table>
<p>There are two key areas to this: using semantic markup, and taking advantage of CSS selectors. Let&#8217;s first fix up our table HTML:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;table border=&quot;1&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;td&gt;Heading 1&lt;/td&gt;
&lt;td&gt;Heading 2&lt;/td&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Value&lt;/td&gt;
&lt;td&gt;Value&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Value&lt;/td&gt;
&lt;td&gt;Value&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</pre></div></div>

<p>And then add some styles:</p>

<div class="wp_syntax"><div class="code"><pre class="css css" style="font-family:monospace;">table <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border-collapse</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">collapse</span>;
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#CCC</span>;
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span>;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
table thead td <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span>;
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#E1E1E1</span>;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
table tbody tr<span style="color: #3333ff;">:hover </span>td <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#F3F3F3</span>;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
table td <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span> <span style="color: #933;">10px</span>;
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>First, notice the use of border collapse - this prevents the blocky double-borders on cells. Next, we take advantage of our &lt;thead&gt; and &lt;tbody&gt; to apply a background color to our header row, but a hover effect on body rows. The :hover is on the table row, but the actual background needs to be applied to the cell. Finally, we add a neat padding that keeps text in order. A smaller font size on your table will also cut it down to size and fit more figures on a page.</p>
<p><strong>3. Button Links</strong><br />
Often you want a button-style link to execute a simple action or lead the user to another page. Let&#8217;s create a simple &#8220;Next&#8221; link with this markup:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;a href=&quot;#&quot; class=&quot;button&quot;&gt;Next &amp;raquo;&lt;/a&gt;</pre></div></div>

<p>We can then style it nicely with this CSS:</p>

<div class="wp_syntax"><div class="code"><pre class="css css" style="font-family:monospace;">a<span style="color: #6666ff;">.button</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#AAA</span>;
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#FFF</span>;
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span> <span style="color: #933;">5px</span>;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
a<span style="color: #6666ff;">.button</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#888</span>;
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>We first set a simple background color on the anchor to make it stand out, and ensure the text is still visible. However, feedback is important here - by adding a simple hover color, we make it clear that this is an interface element and not some ordinary link.</p>
<p><strong>4. Typography</strong><br />
It isn&#8217;t hard to use simple, clean text on your pages, as opposed to the serif-heavy fonts IE and Firefox will default to on Win/Linux. Try adding this to your main stylesheet:</p>

<div class="wp_syntax"><div class="code"><pre class="css css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Arial;
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">95</span>%</span>;
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Arial isn&#8217;t terribly fantastic, but it isn&#8217;t too bad either. (Verdana is also a standard option.) By explicitly setting a font here, you avoid leaving at the mercy of the browser/OS, especially when you may not have testing machines of a particular OS available (e.g. OS X).</p>
<p>With all these techniques in play, we have a nice and usable interface:</p>
<p><img src="http://www.developertutorials.com/blog/wp-content/uploads/2008/07/css-2.png" alt="" title="CSS After" width="166" height="166" class="alignnone size-full wp-image-390" /></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark" style="float:left;">
<div class="d391" style="overflow:hidden">
<div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/four-css-tricks-every-php-web-developer-should-know-391/&amp;title=Four+CSS+Tricks+Every+PHP+%2F+Web+Developer+Should+Know" title="Add to&nbsp;Del.icio.us">Del.icio.us</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/four-css-tricks-every-php-web-developer-should-know-391/&amp;title=Four+CSS+Tricks+Every+PHP+%2F+Web+Developer+Should+Know" title="Add to&nbsp;Digg This">Digg This</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/four-css-tricks-every-php-web-developer-should-know-391/&amp;title=Four+CSS+Tricks+Every+PHP+%2F+Web+Developer+Should+Know" title="Add to&nbsp;Stumble">Stumble</a></div></div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/four-css-tricks-every-php-web-developer-should-know-391/feed/</wfw:commentRss>
		</item>
		<item>
		<title>8 Designers You Didn&#8217;t Know You Idolized</title>
		<link>http://www.developertutorials.com/blog/design/8-designers-you-didnt-know-you-idolized-381/</link>
		<comments>http://www.developertutorials.com/blog/design/8-designers-you-didnt-know-you-idolized-381/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 03:50:29 +0000</pubDate>
		<dc:creator>JonGos</dc:creator>
		
		<category><![CDATA[Design]]></category>

		<category><![CDATA[logo]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/design/8-designers-you-didnt-know-you-idolized-381/</guid>
		<description><![CDATA[The other day I came across an interesting website with tons of factual information about relatively unknown world-class designers that have created brand identities that have shaped the world around us.  It got me thinking about some of my own favorite logos, so I did some research to find out who created them.


Joe Kral
Created: [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I came across an <a href="http://www.logosdesigners.com/">interesting website</a> with tons of factual information about relatively unknown world-class designers that have created brand identities that have shaped the world around us.  It got me thinking about some of my own favorite logos, so I did some research to find out who created them.</p>
<p><span id="more-381"></span></p>
<p><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/06/Facebook.svg/200px-Facebook.svg.png"><br />
<a href="http://www.joekral.org/">Joe Kral</a><br />
Created: Facebook Logo<br />
History: Like the Facebook brand?  Well Joe Kral is <a href="http://www.cubancouncil.com/frm_cardtext_nof.php?id=60">credited with creating</a> it back in 2005 before Facebook was FACEBOOK.</p>
<p><img src="http://www.logosdesigners.com/images/i-love-new-york.gif"><br />
Name: <a href="http://en.wikipedia.org/wiki/Milton_Glaser">Milton Glaser</a><br />
Created: I Love New York<br />
History: Milton created the ubiquitous I Love New York campaign that&#8217;s been ripped off by everyone from Philadelphia to <a href="www.wearepony.com/ ">NewYoungPonyClub</a></p>
<p><img src="http://www.logosdesigners.com/images/fedex-logo.gif"><br />
Name: Lindon Leader<br />
Created: FedEx Logo<br />
History: In the past few years the FedEx logo has become almost more recognizable than the U.S.P.S itself! </p>
<p><img src="http://www.logosdesigners.com/images/ibm-logo.gif"><br />
Name: <a href="http://en.wikipedia.org/wiki/Paul_Rand">Paul Rand (a.k.a Peretz Rosenbaum)</a><br />
Created: IBM Logo<br />
History: Even after his death in 1996, Paul Rand remains one of the most famous graphic designers in the world.  He designed many posters and corporate identities, including the logos for IBM, UPS and ABC.</p>
<p><img src="http://www.logosdesigners.com/images/citi-logo.gif"><br />
Name: <a href="http://www.pentagram.com/en/partners/paula-scher.php">Paula Scher</a><br />
Created: Various Album Covers, Citi Group Logo<br />
History: Paula Scher studied at the Tyler School of Art in Philadelphia and began her graphic design career as a record cover art director at both Atlantic and CBS Records in the 1970s.</p>
<p><img src="http://upload.wikimedia.org/wikipedia/en/5/51/Google.png"><br />
Name: <a href="http://en.wikipedia.org/wiki/Ruth_Kedar">Ruth Kedar</a><br />
Created: The Original Google Logo<br />
History: Ruth Kedar is an artist and designer, best known for designing the Google logo. Her master thesis in school was on Playing cards design, and she was commissioned by Adobe Systems to be one of the designers of the Adobe Deck. She went on to design the award winning Analog Deck and Duolog Deck.</p>
<p><img src="http://www.google.com/logos/mothers_day08.gif"><br />
Name: <a href="http://en.wikipedia.org/wiki/Dennis_Hwang">Dennis Hwang</a> (a.k.a Hwang Jeong-mok)<br />
Created: Google&#8217;s Specialty Logos<br />
History: Hwang&#8217;s actual position in Google&#8217;s early days was as their webmaster.  He began creating custom logos for the company in 2000 at Larry Page and Sergey Prin&#8217;s request.</p>
<p><img src="http://upload.wikimedia.org/wikipedia/en/thumb/a/ab/Apple-logo.png/98px-Apple-logo.png"><br />
Name: <a href="http://en.wikipedia.org/wiki/Rob_Janoff">Rob Janoff</a><br />
Created: The Apple Logo<br />
History: While it is generally accepted to have been in reference to Isaac Newton, a curious urban legend exists that the bitten apple is a homage to the mathematician Alan Turing, who committed suicide by eating an apple he had laced with cyanide. Turing is regarded as one of the fathers of the computer.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark" style="float:left;">
<div class="d381" style="overflow:hidden">
<div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/design/8-designers-you-didnt-know-you-idolized-381/&amp;title=8+Designers+You+Didn%26%238217%3Bt+Know+You+Idolized" title="Add to&nbsp;Del.icio.us">Del.icio.us</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/design/8-designers-you-didnt-know-you-idolized-381/&amp;title=8+Designers+You+Didn%26%238217%3Bt+Know+You+Idolized" title="Add to&nbsp;Digg This">Digg This</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/design/8-designers-you-didnt-know-you-idolized-381/&amp;title=8+Designers+You+Didn%26%238217%3Bt+Know+You+Idolized" title="Add to&nbsp;Stumble">Stumble</a></div></div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/design/8-designers-you-didnt-know-you-idolized-381/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Make Your Next Portfolio in Acrobat 9</title>
		<link>http://www.developertutorials.com/blog/design/make-your-next-portfolio-in-acrobat-9-377/</link>
		<comments>http://www.developertutorials.com/blog/design/make-your-next-portfolio-in-acrobat-9-377/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 20:38:16 +0000</pubDate>
		<dc:creator>JonGos</dc:creator>
		
		<category><![CDATA[Design]]></category>

		<category><![CDATA[adobe]]></category>

		<category><![CDATA[pdf]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/design/make-your-next-portfolio-in-acrobat-9-377/</guid>
		<description><![CDATA[Designers are always looking for new ways to make their portfolios stand out from the pack.  One method that Adobe is promoting is the new feature in Acrobat 9 for PDF Portfolios which allows users to organize a variety of files and compress them as portable PDF documents.
What sets PDF Portfolios apart from other [...]]]></description>
			<content:encoded><![CDATA[<p>Designers are always looking for new ways to make their portfolios stand out from the pack.  One method that Adobe is promoting is <a href="http://blogs.adobe.com/acrobat/2008/07/inside_pdf_portfolios.html">the new feature in Acrobat 9</a> for <a href="http://blogs.adobe.com/educationleaders/2008/06/eportfolios_with_acrobat_9.html">PDF Portfolios</a> which allows users to organize a variety of files and compress them as portable PDF documents.</p>
<p>What sets PDF Portfolios apart from other solutions like Powerpoint, Keynote, Illustrator and Word is the ease of navigation and customization it applies to &#8216;files&#8217;, where as most other solutions only let you embed content, offering little control over how it&#8217;s displayed once embedded.  Click the image for a live demo.</p>
<p><a href="https://admin.adobe.acrobat.com/_a227210/a9sixcoolportfolio/"><img src="http://blogs.adobe.com/acrobat/20080728_portfolio.jpg"></a></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark" style="float:left;">
<div class="d377" style="overflow:hidden">
<div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/design/make-your-next-portfolio-in-acrobat-9-377/&amp;title=Make+Your+Next+Portfolio+in+Acrobat+9" title="Add to&nbsp;Del.icio.us">Del.icio.us</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/design/make-your-next-portfolio-in-acrobat-9-377/&amp;title=Make+Your+Next+Portfolio+in+Acrobat+9" title="Add to&nbsp;Digg This">Digg This</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/design/make-your-next-portfolio-in-acrobat-9-377/&amp;title=Make+Your+Next+Portfolio+in+Acrobat+9" title="Add to&nbsp;Stumble">Stumble</a></div></div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/design/make-your-next-portfolio-in-acrobat-9-377/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Parallel web scraping in PHP: cURL multi functions</title>
		<link>http://www.developertutorials.com/blog/php/parallel-web-scraping-in-php-curl-multi-functions-375/</link>
		<comments>http://www.developertutorials.com/blog/php/parallel-web-scraping-in-php-curl-multi-functions-375/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 13:00:43 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/parallel-web-scraping-in-php-curl-multi-functions-375/</guid>
		<description><![CDATA[For anyone who&#8217;s ever tried to fetch multiple resources over HTTP in PHP, the logic is trivial, but one key challenge is ever-present: latency delays. While web servers have perfectly good downstream links, latencies can increase script execution time tenfold just by downloading a few external URLs. But there&#8217;s a simple solution: parallel cURL operations. [...]]]></description>
			<content:encoded><![CDATA[<p>For anyone who&#8217;s ever tried to fetch multiple resources over HTTP in PHP, the logic is trivial, but one key challenge is ever-present: latency delays. While web servers have perfectly good downstream links, latencies can increase script execution time tenfold just by downloading a few external URLs. But there&#8217;s a simple solution: parallel cURL operations. In this tutorial, I&#8217;ll show you how to use the &#8220;multi&#8221; functions in PHP&#8217;s cURL library to get around this quickly and easily.<span id="more-375"></span></p>
<p>Caching alleviates the latency issue to some extent, but retrieving more than a few files is always going to be a problem, and, well, <a href="http://www.developertutorials.com/blog/php/running-background-processes-in-php-349/">sometimes users just can&#8217;t wait</a>. cURL&#8217;s parallel processing allows you to fire off multiple requests at a time and handle responses as they arrive, instead of linear operations - waiting for each request to complete (or worse, time out) before starting the next.</p>
<p>Consider this basic cURL example:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> curl_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;http://example.com/&quot;</span><span style="color: #009900;">&#41;</span>;
curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> curl_exec<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span>;
&nbsp;
curl_close<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>This will fetch the initial resource of http://example.com/ and put the data (the HTML) in <code>$data</code>. If we wanted to do this multiple times, we could use a simple <code>for</code> loop around this code block and repeat. However, through this method script execution time increases are linear, proportionate to the latencies of each network request, and latencies of 50-100ms x 10 requests don&#8217;t help when you barely spend &lt;10ms executing all your PHP code.</p>
<p>Instead, we&#8217;ll use cURL&#8217;s parallel processing system. This requires a bit of a context shift - instead of running each operation, you now have to tell cURL all the operations to run, let it do it&#8217;s stuff, and then continue on once it has finished. The difference is that it doesn&#8217;t wait for each request - it runs them all simultaneously (network permitting). Here&#8217;s a basic example:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Create two cURL handlers</span>
<span style="color: #000088;">$ch1</span> <span style="color: #339933;">=</span> curl_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>; <span style="color: #000088;">$ch2</span> <span style="color: #339933;">=</span> curl_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">// Set options on both</span>
curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch1</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;http://example.com/&quot;</span><span style="color: #009900;">&#41;</span>;
curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch2</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;http://example2.com/&quot;</span><span style="color: #009900;">&#41;</span>;
curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch1</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>;
curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch2</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #000088;">$mh</span> <span style="color: #339933;">=</span> curl_multi_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
curl_multi_add_handle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mh</span><span style="color: #339933;">,</span><span style="color: #000088;">$ch1</span><span style="color: #009900;">&#41;</span>;
curl_multi_add_handle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mh</span><span style="color: #339933;">,</span><span style="color: #000088;">$ch2</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #000088;">$running</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">null</span>;
<span style="color: #b1b100;">do</span> <span style="color: #009900;">&#123;</span>
    curl_multi_exec<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mh</span><span style="color: #339933;">,</span><span style="color: #000088;">$running</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$running</span> <span style="color: #339933;">&gt;</span> <span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #000088;">$data1</span> <span style="color: #339933;">=</span> curl_multi_getcontent<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch1</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$data2</span> <span style="color: #339933;">=</span> curl_multi_getcontent<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch2</span><span style="color: #009900;">&#41;</span>;
&nbsp;
curl_multi_remove_handle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch1</span><span style="color: #009900;">&#41;</span>;
curl_multi_remove_handle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch2</span><span style="color: #009900;">&#41;</span>;
curl_multi_close<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mh</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Here, we first create a cURL connection object for each request we want to make - an array of these is perfectly acceptable - and set the options on each. Instead of <code>curl_init()</code>, we then call <code>curl_multi_init()</code> and point the library at each of our connection objects. We have to cede control from cURL at this point: <code>curl_multi_exec()</code> now runs all the sub-connections of the current cURL object - that is, <code>$ch1</code> and <code>$ch2</code>.</p>
<p>The <code>curl_multi_exec()</code> function takes a second parameter, a reference to a flag of whether operations are still running. When that parameter - for us, <code>$running</code> - is 0, cURL&#8217;s finished taking care of requests and we can proceed. Timeouts are the only concern - remember to set the timeout option to a reasonable value to avoid being held up by requests that won&#8217;t complete.</p>
<p>As you increase in requests, however, remember that the next bottleneck you will hit is memory. Given PHP&#8217;s memory_limit flag (especially on shared servers), you can actually hit this quicker than you think. cURL can&#8217;t read part of a file or stream, even if it&#8217;s packet-based. Ever seen <code>fread($handle, 8192)</code>? The second parameter results in 8KB chunks, avoiding memory limits elegantly. cURL, however, will simply collect up all your request responses: if you hit your memory limit, you either get a fatal error or a &#8220;white screen of death&#8221;. Consider parallel cURL-ing in <a href="http://www.developertutorials.com/blog/php/running-background-processes-in-php-349/">a background process</a>. Also, these simple routines can get quite lengthy - consider building an abstraction layer for your app/framework, to maintain an array of cURL connection objects and interface requests.</p>
<p>Parallel HTTP requests in cURL are quick and easy, despite the architectural differences with libraries for single-threaded cURL. To learn more, just check out the detailed documentation on the <a href="http://php.net/manual/en/function.curl-multi-exec.php">PHP manual page</a>.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark" style="float:left;">
<div class="d375" style="overflow:hidden">
<div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/parallel-web-scraping-in-php-curl-multi-functions-375/&amp;title=Parallel+web+scraping+in+PHP%3A+cURL+multi+functions" title="Add to&nbsp;Del.icio.us">Del.icio.us</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/parallel-web-scraping-in-php-curl-multi-functions-375/&amp;title=Parallel+web+scraping+in+PHP%3A+cURL+multi+functions" title="Add to&nbsp;Digg This">Digg This</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/parallel-web-scraping-in-php-curl-multi-functions-375/&amp;title=Parallel+web+scraping+in+PHP%3A+cURL+multi+functions" title="Add to&nbsp;Stumble">Stumble</a></div></div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/parallel-web-scraping-in-php-curl-multi-functions-375/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Five Handy Web Development Bookmarklets</title>
		<link>http://www.developertutorials.com/blog/web/five-handy-web-development-bookmarklets-367/</link>
		<comments>http://www.developertutorials.com/blog/web/five-handy-web-development-bookmarklets-367/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 13:08:24 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/web/five-handy-web-development-bookmarklets-367/</guid>
		<description><![CDATA[When developing a UI for your web application, it&#8217;s easy to lose a lot of time waiting for reloads, dealing with browser quirks, even just trying to identify a particular element in the DOM. Here are five handy bookmarklets that will help you finish your client-side web development faster and more effectively.
1. ReCSS
ReCSS makes testing [...]]]></description>
			<content:encoded><![CDATA[<p>When developing a UI for your web application, it&#8217;s easy to lose a lot of time waiting for reloads, dealing with browser quirks, even just trying to identify a particular element in the DOM. Here are five handy bookmarklets that will help you finish your client-side web development faster and more effectively.<span id="more-367"></span></p>
<p><strong>1. ReCSS</strong><br />
ReCSS makes testing out CSS hacks easy. When you alter your CSS in an editor and save the new stylesheet, you have to reload the entire page in your browser to see the effect of the changes. Sure, you can make the edits in Firebug, but Firebug&#8217;s inbuilt editor isn&#8217;t great for much beyond the slight tweak. With AJAX-powered pages and dynamic state, reloading the page isn&#8217;t quite as simple as it sounds.</p>
<p>Enter ReCSS: this handy little bookmarklet will keep your existing page entirely intact, but reload all the CSS sheets. You may see a brief flash of white in your browser as current styles are removed, before your page renders almost immediately with the latest set of CSS rules. Check out the <a href="http://turtle.dojotoolkit.org/~david/recss.html">project page</a>.</p>
<p><strong>2. Layout Grid Bookmarklet</strong><br />
Working out pixels and laying out a page is tricky, especially when working from detailed Photoshop mockups and sketches. After some suggestions from the community about using a <a href="http://www.subtraction.com/archives/2004/1231_grid_computi.php">background image of a grid for layout</a>, Andy Budd created the Layout Grid Bookmarklet, which creates a drawing-paper style grid against the background of your page to generally measure elements with. Check out his <a href="http://www.andybudd.com/archives/2006/07/layout_grid_bookmarklet/">blog post about it</a> and the <a href="javascript:void(d=document);void(el=d.getElementsByTagName('body'));void(el%5B0%5D.style.background='url(http://www.andybudd.com/images/layoutgrid.png)');">Layout Grid Bookmarklet</a>.</p>
<p><strong>3. XRAY</strong><br />
X-RAY is a great Firebug/Safari/IE Dev-bar style inspector for web pages. It features a simple point-and-click interface, revealing some basic CSS properties and inheritance hierarchy of the selected element, as well as outlining it and displaying dimensions details. The actual interface is quite slick, and hides away neatly when you no longer want it. If you aren&#8217;t at your preferred Firebug-equipped machine, XRAY is definitely something to have on hand. Check out the <a href="http://westciv.com/xray/">project page</a> and the <a href="javascript:function%20loadScript(scriptURL)%20{%20var%20scriptElem%20=%20document.createElement('SCRIPT');%20scriptElem.setAttribute('language',%20'JavaScript');%20scriptElem.setAttribute('src',%20scriptURL);%20document.body.appendChild(scriptElem);}loadScript('http://westciv.com/xray/thexray.js');">XRAY</a> bookmarklet.</p>
<p><strong>4. Aardvark</strong><br />
Aardvark is similar to XRAY, but provides a lot more functionality for traversing the DOM visually. Ever wanted to pick a particular element, then see what happens if you move up n levels, go to the next node across, or even dive in and start editing innerHTML there and then? Aardvark provides a point-and-click interface similar to XRAY, and then a set of keyboard shortcuts for moving around, focusing on finding what you need. Aardvark is actually available as a Firefox extension, although the bookmarklet is quite convenient. Head to the <a href="http://karmatics.com/aardvark/">project page</a> and try the <a href="javascript:document.getElementsByTagName('head')[0].appendChild(document.createElement('script')).setAttribute('src','http://www.karmatics.com/aardvark/loader.js')">Aardvark</a> bookmarklet.</p>
<p><strong>5. Slayeroffice Favelet Suite</strong><br />
We&#8217;ve saved the best till last - this favelet suite will blow you away. It features everything from DOM charts to mouseover inspectors, color lists to font resizers, rulers and even a hidden field modifier. All in all, this collection of 15 utilities all in the one bookmarklet is a must for any front-end web development. While it was last revised in 2004, it in many ways offers far more functionality than Firebug, with far more detail provided by its various tools. When you&#8217;ve finished with it it, just hit escape to quietly hide it away. Head to the <a href="http://slayeroffice.com/?c=/content/tools/suite.html">project page</a> and grab the <a href="javascript:s=document.body.appendChild(document.createElement('script'));s.id='fs';s.language='javascript';void(s.src='http://slayeroffice.com/tools/suite/suite.js');">Favelet suite</a>.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark" style="float:left;">
<div class="d367" style="overflow:hidden">
<div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/web/five-handy-web-development-bookmarklets-367/&amp;title=Five+Handy+Web+Development+Bookmarklets" title="Add to&nbsp;Del.icio.us">Del.icio.us</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/web/five-handy-web-development-bookmarklets-367/&amp;title=Five+Handy+Web+Development+Bookmarklets" title="Add to&nbsp;Digg This">Digg This</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/web/five-handy-web-development-bookmarklets-367/&amp;title=Five+Handy+Web+Development+Bookmarklets" title="Add to&nbsp;Stumble">Stumble</a></div></div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/web/five-handy-web-development-bookmarklets-367/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Debugging PHP with Firebug and FirePHP</title>
		<link>http://www.developertutorials.com/blog/php/debugging-php-with-firebug-and-firephp-365/</link>
		<comments>http://www.developertutorials.com/blog/php/debugging-php-with-firebug-and-firephp-365/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 09:00:32 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/debugging-php-with-firebug-and-firephp-365/</guid>
		<description><![CDATA[FirePHP is a plugin for Firebug, the web development plugin for Firefox, that allows PHP scripts to talk to a Firebug panel. FirePHP installs alongside Firebug, and provides a simple PHP library to bridge the two. FirePHP provides a window of insight into your PHP applications, with a simple debugging interface that won&#8217;t interfere with [...]]]></description>
			<content:encoded><![CDATA[<p>FirePHP is a plugin for Firebug, the web development plugin for Firefox, that allows PHP scripts to talk to a Firebug panel. FirePHP installs alongside Firebug, and provides a simple PHP library to bridge the two. FirePHP provides a window of insight into your PHP applications, with a simple debugging interface that won&#8217;t interfere with your page content. If you already use Firebug on PHP-powered applications, FirePHP is definitely worth a look. Here&#8217;s a quick guide to getting started.<span id="more-365"></span></p>
<p>FirePHP is implemented as a native Firefox extension, and is available from <a href="https://addons.mozilla.org/en-US/firefox/addon/6149">Mozilla Addons</a>. After a basic setup procedure, you can start printing everything from status messages to multi-dimensional arrays straight to your Firebug console. FirePHP achieves this using extension HTTP headers - in particular, X-FirePHP-Data headers in the response.</p>
<p>The PHP library provides a function, <code>fb()</code>, which handles sending data across to the client side. From here, you simply open up your Firebug console, and your data is displayed in a highly functional manner.</p>
<p>To get started with FirePHP, grab the extension from <a href="https://addons.mozilla.org/en-US/firefox/addon/6149">Mozilla Addons</a> and the core library from the <a href="http://www.firephp.org/" target="_blank">FirePHP project page</a> (the &#8220;Download&#8221; link). You&#8217;ll need to install Firebug first, then the FirePHP Firefox addon. Next we get to the PHP library - either add the &#8220;FirePHPCore&#8221; folder to somewhere in your include_path, or just pop it into your script directory, and include it:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="">'FirePHPCore/fb.php'</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>Remember to change the relative path as required (no pun intended). Then, simply call the <code>fb()</code> function anywhere in your code, passing a single argument - the info you want to send to your FirePHP console. Here are some examples:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;">fb<span style="color: #009900;">&#40;</span><span style="">'The value of $var is '</span><span style="color: #339933;">.</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span>;
fb<span style="color: #009900;">&#40;</span><span style="">'Just logging this event.'</span><span style="color: #339933;">,</span>FirePHP<span style="color: #339933;">::</span><span style="color: #990000;">LOG</span><span style="color: #009900;">&#41;</span>;
fb<span style="color: #009900;">&#40;</span><span style="">'Error in the email module.'</span><span style="color: #339933;">,</span>FirePHP<span style="color: #339933;">::</span><span style="color: #004000;">ERROR</span><span style="color: #009900;">&#41;</span>;
fb<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #339933;">,</span> <span style="">'$_SERVER array'</span><span style="color: #339933;">,</span> FirePHP<span style="color: #339933;">::</span><span style="color: #990000;">LOG</span><span style="color: #009900;">&#41;</span>;
&nbsp;
try <span style="color: #009900;">&#123;</span>
  throw <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="">'Exception'</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span> catch<span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  fb<span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>As you can see, we can output basic messages, use Firebug&#8217;s standard styles to identify message importance (also, INFO and WARN), output labelled assocative arrays, and even debug exceptions - FirePHP will display a neat little stack trace.</p>
<p>Remember that this information is sent via headers, so it needs to be output before any of your HTML. If you&#8217;re using a framework with view templates, this is probably not an issue, but otherwise, you can get around the problem by using output buffering. Just run this line somewhere near the beginning of your script execution:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>This will initialise output buffering, so that any HTML you output is held up till the end of script execution (or till the next call to <code>ob_flush()</code> and derivatives). Calling the <code>fb()</code> function will then work fine any time before the end of your script, as the headers will be flushed immediately. (Alternatively you can use <code>php_flag output_buffering on</code> in your .htaccess / apache virtual host configuration.)</p>
<p>FirePHP has all sorts of neat tips and tricks - just check out the <a href="http://www.firephp.org/Wiki/Main/QuickStart">quick start guide</a> and <a href="http://www.firephp.org/Wiki/Reference/Protocol">protocol reference</a>. If you use the Zend Framework, have a look at the <a href="http://www.firephp.org/Wiki/Libraries/ZendFramework" target="_blank">Zend library for FirePHP</a>; similar libraries exist for Symfony and Prado as well.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark" style="float:left;">
<div class="d365" style="overflow:hidden">
<div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/debugging-php-with-firebug-and-firephp-365/&amp;title=Debugging+PHP+with+Firebug+and+FirePHP" title="Add to&nbsp;Del.icio.us">Del.icio.us</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/debugging-php-with-firebug-and-firephp-365/&amp;title=Debugging+PHP+with+Firebug+and+FirePHP" title="Add to&nbsp;Digg This">Digg This</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/debugging-php-with-firebug-and-firephp-365/&amp;title=Debugging+PHP+with+Firebug+and+FirePHP" title="Add to&nbsp;Stumble">Stumble</a></div></div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/debugging-php-with-firebug-and-firephp-365/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Five Tools For Faking Advanced CSS</title>
		<link>http://www.developertutorials.com/blog/design/five-tools-for-faking-advanced-css-352/</link>
		<comments>http://www.developertutorials.com/blog/design/five-tools-for-faking-advanced-css-352/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 03:42:22 +0000</pubDate>
		<dc:creator>JonGos</dc:creator>
		
		<category><![CDATA[Design]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[hack]]></category>

		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/design/five-tools-for-faking-advanced-css-352/</guid>
		<description><![CDATA[When some people find a well-designed blog with a few neat tricks, they tend to automatically assume the owner is a CSS genius who&#8217;s the next big designer to hit the web.  That very well may be the case but more often than not the designer is using &#8216;tools&#8217; that you just haven&#8217;t discovered [...]]]></description>
			<content:encoded><![CDATA[<p>When some people find a well-designed blog with a few neat tricks, they tend to automatically assume the owner is a CSS genius who&#8217;s the next big designer to hit the web.  That very well may be the case but more often than not the designer is using &#8216;tools&#8217; that you just haven&#8217;t discovered yet. Here&#8217;s five web generators that will make you look like <a href="http://www.ndesign-studio.com/" target="_blank">Nick La</a>! </p>
<p><span id="more-352"></span></p>
<p><a href="http://www.developertutorials.com/blog/wp-content/uploads/2008/07/picture-22.png"><img src="http://www.developertutorials.com/blog/wp-content/uploads/2008/07/picture-22-300x115.png" alt="" width="300" height="115" class="alignnone size-medium wp-image-353" /></a></p>
<p><strong><a href="http://csstypeset.com/" target="_blank">CSSTypeset</a></strong><br />
CSSTypset is handy tool for seeing the effect of CSS code while simultaneously seeing what&#8217;s going on behind the scenes with the actual code.  It works both ways, you can type code and immediately see it applied to text, or you can type text and use a GUI with sliders to apply CSS to your text.  If you have a hard time figuring out the difference between <strong>em</strong> and <strong>px</strong>, <strong>verdana</strong> and <strong>helvetica</strong> then this is the tool for you.</p>
<p><strong><a href="http://www.text2png.com/" target="_blank">Text2PNG</a></strong><br />
Add a few lines of javascript to your header and this nifty web tool converts your headlines to images automatically.</p>
<p><a href="http://www.developertutorials.com/blog/wp-content/uploads/2008/07/picture-3.png"><img src="http://www.developertutorials.com/blog/wp-content/uploads/2008/07/picture-3-300x139.png" alt="" width="300" height="139" class="alignnone size-medium wp-image-354" /></a></p>
<p><strong><a href="http://www.csstextwrap.com/" target="_blank">CSSTextWrap</a></strong><br />
Sick of &#8216;designing to an invisible grid&#8217;?  Turn that grid into origami and spice up your layouts with this incredible text wrap tool.</p>
<p><a href="http://www.developertutorials.com/blog/wp-content/uploads/2008/07/picture-62.png"><img src="http://www.developertutorials.com/blog/wp-content/uploads/2008/07/picture-62-300x106.png" alt="" width="300" height="106" class="alignnone size-medium wp-image-357" /></a></p>
<p><strong><a href="http://www.askthecssguy.com/kotatsu/index.html" target="_blank">Kotatsu</a></strong><br />
A wrote <a href="http://www.developertutorials.com/blog/design/grunge-tables-with-photoshop-and-xhtml-part-1-186/">a tutorial a while back</a> about how to make XHTML tables that could be marked up with PHP, Javascript or Ajax.  If only I had known about this tool then!  Essentially it&#8217;s a HTML table generator.</p>
<p><a href="http://www.developertutorials.com/blog/wp-content/uploads/2008/07/picture-5.png"><img src="http://www.developertutorials.com/blog/wp-content/uploads/2008/07/picture-5-300x189.png" alt="" width="300" height="189" class="alignnone size-medium wp-image-355" /></a></p>
<p><strong><a href="http://goldenratiocalculator.com/" target="_blank">GoldenRationCalculator</a></strong><br />
Divine proportions have been used for all types of creative work, from architecture to print layout to photography.  It&#8217;s only natural that it also eventually found it&#8217;s way into web design.  This web generator makes it easy to design using the &#8216;golden ratio&#8217; as the underlying framework for your website&#8217;s design.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark" style="float:left;">
<div class="d352" style="overflow:hidden">
<div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/design/five-tools-for-faking-advanced-css-352/&amp;title=Five+Tools+For+Faking+Advanced+CSS" title="Add to&nbsp;Del.icio.us">Del.icio.us</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/design/five-tools-for-faking-advanced-css-352/&amp;title=Five+Tools+For+Faking+Advanced+CSS" title="Add to&nbsp;Digg This">Digg This</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/design/five-tools-for-faking-advanced-css-352/&amp;title=Five+Tools+For+Faking+Advanced+CSS" title="Add to&nbsp;Stumble">Stumble</a></div></div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/design/five-tools-for-faking-advanced-css-352/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Running background processes in PHP</title>
		<link>http://www.developertutorials.com/blog/php/running-background-processes-in-php-349/</link>
		<comments>http://www.developertutorials.com/blog/php/running-background-processes-in-php-349/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 10:00:14 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/running-background-processes-in-php-349/</guid>
		<description><![CDATA[So you&#8217;ve just built a fantastic processing routine for your application. You&#8217;ve checked and double checked the integrity of user input, and you&#8217;re doing some serious processing. There&#8217;s only one problem: it&#8217;s too slow. There&#8217;s a simple solution: forking your processing script, and running the code as a background process asynchronously. It can email your [...]]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;ve just built a fantastic processing routine for your application. You&#8217;ve checked and double checked the integrity of user input, and you&#8217;re doing some serious processing. There&#8217;s only one problem: it&#8217;s too slow. There&#8217;s a simple solution: forking your processing script, and running the code as a background process asynchronously. It can email your user when it&#8217;s done: they&#8217;ll wait. In this tutorial, I&#8217;ll show you how to get started with background processes in PHP.<span id="more-349"></span></p>
<p>When we want some kind of background process running our PHP code, we have a simple challenge: we can&#8217;t leave it up to the client. On the web, people hit their stop button, their browsers lock up and they force quit, they even have the odd power outage. When we want to do complex processing on the server side, we need to detach from the client-server model of a web-served script. PHP can fork a script, but the parent script is still facing an unreliable client.</p>
<p>Our best option, then, is to launch a background process from the command line. There are three steps to this: starting the background script, passing it information to do its job, and checking when it&#8217;s finished.</p>
<p><strong>Starting the background script</strong><br />
On UNIX systems, we can easily call another PHP script via the shell, set it to run off in the background and send its output to /dev/null. Here&#8217;s a sample:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #990000;">exec</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/usr/bin/php proc.php &gt;/dev/null &amp;#038;&quot;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>Here, we call the <code>exec</code> function; instructing it to run our local PHP binary - usually at /usr/bin/php or /usr/local/bin/php, check with your host/sysadmin. We pass it a single argument: the filename of the PHP script that handles our background process. We then send the output to /dev/null, effectively destroying it. The last character, the &amp; symbol, is important - this tells the system to start this process in the background and to let us continue.</p>
<p><strong>Talking to the background process</strong><br />
It&#8217;s all very well to start a background process, but now it needs to know what to do. We handle this through command line arguments. Let&#8217;s update the previous example:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #990000;">exec</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/usr/bin/php proc.php --task=50 &gt;/dev/null &amp;#038;&quot;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>Our proc.php file might look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;Handling process &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>;</pre></div></div>

<p>Running &#8220;php proc.php &#8211;task=50&#8243; on command line produces the following output:</p>
<pre>Handling process --task=50</pre>
<p>From here, you can easily design your script to do what it needs to.</p>
<p><strong>Monitoring the background process</strong><br />
There&#8217;s just one last detail: how do we monitor the progress of our background process? It&#8217;s best to use an independent datastore that can be relied upon, instead of communicating with running threads - your application&#8217;s MySQL database would be perfect. You can create a &#8220;sessions&#8221; or &#8220;jobs&#8221; table with an ID column, a status column (started, in progress, finished - 0, 1, 2), and any other information you need. Before you start your background process, create a new entry in this table and check the insert ID, then pass it to the background process when you start it:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #990000;">exec</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/usr/bin/php proc.php --some_info=50 --job=1234 &gt;/dev/null &amp;#038;&quot;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>Your proc.php file can then update the table row with the ID you supply it, and your front end applications can provide status updates to end users by checking up on all pending jobs for the current user - relatively straightforward business logic.</p>
<p>If you&#8217;re going to be running many background processes, a job queue and an &#8220;always-on&#8221; script running on your server may also be an option. In this case, consider looking into <a href="http://php.net/pcntl_fork">pcntl_fork()</a> and the <a href="http://www.developertutorials.com/php-manual/ref.exec.html">program execution functions</a>.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark" style="float:left;">
<div class="d349" style="overflow:hidden">
<div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/running-background-processes-in-php-349/&amp;title=Running+background+processes+in+PHP" title="Add to&nbsp;Del.icio.us">Del.icio.us</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/running-background-processes-in-php-349/&amp;title=Running+background+processes+in+PHP" title="Add to&nbsp;Digg This">Digg This</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/running-background-processes-in-php-349/&amp;title=Running+background+processes+in+PHP" title="Add to&nbsp;Stumble">Stumble</a></div></div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/running-background-processes-in-php-349/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
