<?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>Young Dutch Design &#187; PHP</title>
	<atom:link href="http://youngdutchdesign.com/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://youngdutchdesign.com</link>
	<description>Young Dutch Design is a new platform for young designers with frequently new added postings about productdesign, webdesign and other related subjects.</description>
	<lastBuildDate>Tue, 14 Jun 2011 20:25:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Zebra tables with php</title>
		<link>http://youngdutchdesign.com/zebra-tables-with-php</link>
		<comments>http://youngdutchdesign.com/zebra-tables-with-php#comments</comments>
		<pubDate>Thu, 03 Feb 2011 19:37:15 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Starting with php]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=3525</guid>
		<description><![CDATA[Zebra tables are very easy to read and they are very nice to look at if you style them correctly. But how do you accomplish this? Well, here I am with a very basic example. There are a lot of methods but this is the one I&#8217;m using. Please note that $this-&#62;records has to be [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-4003" title="Screen shot 2011-02-03 at 20.36.22" src="http://youngdutchdesign.com/wp-content/uploads/2011/02/Screen-shot-2011-02-03-at-20.36.22-.png" alt="" width="261" height="150" />Zebra tables are very easy to read and they are very nice to look at if you style them correctly. But how do you accomplish this?</p>
<p>Well, here I am with a very basic example. There are a lot of methods but this is the one I&#8217;m using.<span id="more-3525"></span></p>
<p>Please note that $this-&gt;records has to be an array, generated by a fetched query or something like that. Place this script between the &lt;tbody&gt; tags.</p>
<pre class="php">$bool = 0;
foreach($this-&gt;records as $row):
	echo ($bool++ &amp; 1) ? 'class="even"' : 'class="steven"';
endforeach;
</pre>
<p>Use this css for example and add it to a &lt;tr&gt; element.</p>
<pre class="css">.even {
	background-color: #FFF;
	}

.steven {
	background-color: #F9F9F9;
	}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/zebra-tables-with-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Verot.net Upload Class with Zend Framework</title>
		<link>http://youngdutchdesign.com/verot-net-upload-class-with-zend-framework</link>
		<comments>http://youngdutchdesign.com/verot-net-upload-class-with-zend-framework#comments</comments>
		<pubDate>Fri, 25 Jun 2010 19:40:49 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=3548</guid>
		<description><![CDATA[Almost a year ago I posted something about the verot.net upload class. Now I&#8217;m learning Zend Framework and ZF doesn&#8217;t support image manipulation I&#8217;d like to add the upload class to ZF. Here&#8217;s how. Step 1 Download the latest release of Upload Class from Colin Verot&#8217;s blog. Step 2 Copy the file class.upload.php to your [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://youngdutchdesign.com/wp-content/uploads/2009/09/upload.jpg"><img class="alignright size-full wp-image-1603" title="upload" src="http://youngdutchdesign.com/wp-content/uploads/2009/09/upload.jpg" alt="" width="190" height="197" /></a>Almost a year ago I posted something about the verot.net upload class. Now I&#8217;m learning Zend Framework and ZF doesn&#8217;t support image manipulation I&#8217;d like to add the upload class to ZF. Here&#8217;s how.</p>
<h2>Step 1</h2>
<p>Download the latest release of Upload Class from <a href="http://www.verot.net/php_class_upload_download.htm" target="_blank">Colin Verot&#8217;s blog</a>.<span id="more-3548"></span></p>
<h2>Step 2</h2>
<p>Copy the file class.upload.php to your <strong>models</strong> directory and rename it to <strong>Upload.php</strong></p>
<ul>
<li>Sitename
<ul>
<li>application
<ul>
<li>models
<ul>
<li>Upload.php</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2>Step 3</h2>
<p>Edit the file <strong>Upload.php</strong> and change the following line (line 528 in version 0.29)</p>
<pre class="php">class upload {</pre>
<p>to</p>
<pre class="php">class Application_Model_Upload { /* It's in the models directory remember? */</pre>
<h2>This is it</h2>
<p>(It&#8217;s 25 June remember? <img src='http://youngdutchdesign.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ) To use the class just create a new instance and do the thinghies you did before!</p>
<pre class="php">$handle = new Upload($_FILES['my_field']);
	if ($handle-&gt;uploaded) {
		/* do thinghies */
	}</pre>
<p>If you&#8217;d like to read more about uploading files with Zend Framework I can recommend you <a href="http://ahsangill.wordpress.com/2009/02/17/zend-framework-file-upload-using-zend_form_element_file/">this tutorial</a>.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/verot-net-upload-class-with-zend-framework/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Php part for cvLinkSelect class</title>
		<link>http://youngdutchdesign.com/php-part-for-cvlinkselect-class</link>
		<comments>http://youngdutchdesign.com/php-part-for-cvlinkselect-class#comments</comments>
		<pubDate>Sat, 20 Feb 2010 17:57:11 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[cvLinkSelect]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=3315</guid>
		<description><![CDATA[I&#8217;m very happy that a lot of developers have found my cvLinkSelect class and found it useful. cvLinkSelect is a simple Mootools 1.2 class that links form select elements based on the previous value via JSON requests. The php part was very basic though and a visitor pointed me to write the php part better, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://youngdutchdesign.com/examples/cvlinkselect.php"><img class="alignright size-full wp-image-3334" title="cvLinkSelect Example" src="http://youngdutchdesign.com/wp-content/uploads/2010/02/Screen-shot-2010-02-20-at-19.34.57-.png" alt="" width="253" height="135" /></a>I&#8217;m very happy that a lot of developers have found my <a href="http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class">cvLinkSelect class</a> and found it useful. cvLinkSelect is a simple Mootools 1.2 class that links form select elements based on the previous value via JSON requests. The php part was very basic though and a visitor pointed me to write the php part better, shorter and more functional. And here we are, just a simple 10 line php function.</p>
<p>In most cases you&#8217;ll get the data from a SQL database or something like that and in therefore it&#8217;s an array.</p>
<pre class="php">/* $arr = array from the database */
$arr = array(//array(id,name),
			 	array(15,'15 inch'),
				array(17,'17 inch'),
				array(19,'19 inch')
			);</pre>
<p><span id="more-3315"></span>Make sure that the you&#8217;ll only get the id and the name or another identifier. The total has to be two otherwise it don&#8217;t work.</p>
<p>To get the JSON request in the right format I&#8217;ve written a small function that will add the <strong>value</strong> and <strong>html</strong> key to the arrays.</p>
<pre class="php">/**
* Function to set the key for each value
* Requires: array(array())
* Returns: JSON format for cvLinkSelect class
*/
function json_cvLinkSelect($arr = array()){
	$json = array(); /* temporary array */

	foreach($arr as $ob){ /*walk trough the original array */
		$keys = array('value','html'); /*define the two keys */
		array_push($json,array_combine($keys,$ob)); /* push the new array to the temporary array, $json */
	}

	return json_encode($json); /* return the $json array */
}</pre>
<p>The output will be:</p>
<pre class="html">[{"value":"hard","html":"Hard"},{"value":"soft","html":"Soft"}]</pre>
<p>I&#8217;ve updated the zipfile with the working example if you guys need more info.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/php-part-for-cvlinkselect-class/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rewrite $_GET variables for WordPress plugins</title>
		<link>http://youngdutchdesign.com/rewrite-multiple-get-variables-for-wordpress-plugins</link>
		<comments>http://youngdutchdesign.com/rewrite-multiple-get-variables-for-wordpress-plugins#comments</comments>
		<pubDate>Wed, 18 Nov 2009 16:29:23 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=1566</guid>
		<description><![CDATA[A while ago I was figuring out how to rewrite GET variables for a wordpress plugin. For example: http://mysite.com/mypage/?myvar=test rewriting to http://mysite.com/mypage/test After a long search on the WordPress forums and the whole internet I&#8217;ve found this topic: using an extra parameter in an URL but it wasn&#8217;t very sufficient in my opinion. So that&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1570" title="get" src="http://youngdutchdesign.com/wp-content/uploads/2009/08/get1.jpg" alt="get" width="200" height="100" />A while ago I was figuring out how to rewrite GET variables for a wordpress plugin. For example:</p>
<p style="padding-left: 30px;">http://mysite.com/mypage/?myvar=test</p>
<p>rewriting to</p>
<p style="padding-left: 30px;">http://mysite.com/mypage/test</p>
<p>After a long search on the WordPress forums and the whole internet I&#8217;ve found this topic: <a href="http://wordpress.org/support/topic/208830" target="_blank">using an extra parameter in an URL</a> but it wasn&#8217;t very sufficient in my opinion. So that&#8217;s why I&#8217;ll explain the use of multiple parameters in the url.<br />
<span id="more-1566"></span></p>
<h2>One $_GET variable</h2>
<pre class="php">function add_mypage_var($public_query_vars) {
$public_query_vars[] = 'myvar1';
return $public_query_vars;
}

//add a rewrite rule
function do_rewrite_mypage() {
add_rewrite_rule('brands/([^/]+)/?$', 'index.php?pagename=mypage&amp;myvar1=$matches[1]','top');
}

add_filter('query_vars', 'add_mypage_var');
add_action('init', 'do_rewrite_brands');</pre>
<p>You can use this variable in a plugin like this:</p>
<pre class="php">$slug = get_query_var('myvar');</pre>
<h2>Multiple $_GET variables</h2>
<p>There was just one thing that cost me a headache&#8230; I&#8217;d like to add multiple parameters to the url and this method I just described isn&#8217;t sufficient. I&#8217;ve checked the basic url rewrite trough mod_rewrite and this method needs several lines to declare all the possible amount of variables in the url. I&#8217;ve tried this method also for the url rewrites via WordPress and here we are: a simple working function:</p>
<pre class="php">function add_mypage_var($public_query_vars) {
	$public_query_vars[] = 'myvar1';
	$public_query_vars[] = 'myvar2';

	return $public_query_vars;
}

//add a rewrite rule
function do_rewrite_mypage() {
	add_rewrite_rule('brands/([^/]+)/?$', 'index.php?pagename=mypage&amp;myvar1=$matches[1]&amp;myvar2=$matches[2]','top');
	add_rewrite_rule('brands/([^/]+)/?$', 'index.php?pagename=mypage&amp;myvar1=$matches[1]','top');
}

add_filter('query_vars', 'add_mypage_var');
add_action('init', 'do_rewrite_mypage');</pre>
<p>You can check all the url rewrites that are used for your WordPress post.</p>
<pre class="php">function get_rewrite_urls(){
	global $wp_rewrite;

	return $wp_rewrite-&gt;wp_rewrite_rules(); /* Returns an array */
}

print_r(get_rewrite_urls());</pre>
<h2>flush_rules</h2>
<p>You need to flush your rules to install your plugin and make the rewrite work. Also it can be handy to flush the rules during your development phase. So, just detect if the plugin is going to be installed:</p>
<pre class="php">register_activation_hook(__FILE__,'do_flush_gear'); /* Place this at the bottom of your plugin file */
</pre>
<p>And in some cases you&#8217;d like to remove all your custom rewrites. Just use this function:</p>
<pre class="php">function do_flush_gear{
	global $wp_rewrite;

	$wp_rewrite-&gt;flush_rules();
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/rewrite-multiple-get-variables-for-wordpress-plugins/feed</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Mootools 1.2 cvLinkSelect class 1.1</title>
		<link>http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class-1-1</link>
		<comments>http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class-1-1#comments</comments>
		<pubDate>Mon, 02 Nov 2009 06:48:04 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Json]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XML / XHTML]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=1708</guid>
		<description><![CDATA[Yesterday I&#8217;ve published the first version of the cvLinkSelect class for Mootools 1.2. Today I&#8217;ve released the new version of this nifty little class. I&#8217;ve completed the class with several finishing touches! View example Download file Changes Multiple GET variables in the request url. After a page refresh the script checks if the first linked [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1712" title="screenshot.185" src="http://youngdutchdesign.com/wp-content/uploads/2009/11/screenshot.185.jpeg" alt="screenshot.185" width="300" height="135" />Yesterday I&#8217;ve published the first version of the <a href="http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class">cvLinkSelect class for Mootools 1.2</a>. Today I&#8217;ve released the new version of this nifty little class. I&#8217;ve completed the class with several finishing touches!</p>
<p><a class="example_but demo" href="http://youngdutchdesign.com/examples/cvlinkselect1.1.php">View example</a> <a class="example_but download" href="http://youngdutchdesign.com/examples/js/cvLinkSelect1.1.js">Download file</a></p>
<h2>Changes</h2>
<ul>
<li>Multiple GET variables in the request url.</li>
<li>After a page refresh the script checks if the first linked selectbox option is not empty. If it isn&#8217;t empty the first request fires.</li>
<li>If the request is empty it&#8217;s the last item in the linked selectboxes range. In this case we have to fire the isLast function.</li>
</ul>
<p>Read more about the usage on the original post for the <a href="http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class">cvLinkSelect class</a>!</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/mootools-1-2-cvlinkselect-class-1-1/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MooDrop: Mootools Eyedropper tool</title>
		<link>http://youngdutchdesign.com/moodrop-mootools-eyedropper-tool</link>
		<comments>http://youngdutchdesign.com/moodrop-mootools-eyedropper-tool#comments</comments>
		<pubDate>Thu, 24 Sep 2009 15:54:04 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Json]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=1595</guid>
		<description><![CDATA[For a new application I&#8217;m working on I&#8217;ve searched the internet for a javascript based eyedropper tool. Fortunately I only found some Java based applications and I&#8217;m not a big fan of those. So I decided to write my own Eyedropper. Test it and install it on your own website! You can tweak some events [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1639" title="moodrop" src="http://youngdutchdesign.com/wp-content/uploads/2009/09/moodrop.jpg" alt="moodrop" width="200" height="200" />For a new application I&#8217;m working on I&#8217;ve searched the internet for a javascript based eyedropper tool. Fortunately I only found some Java based applications and I&#8217;m not a big fan of those.</p>
<p>So I decided to write my own Eyedropper. Test it and install it on your own website! You can tweak some events so it has more functionality.</p>
<p>There is also a Zip file available with a working example. Just upload the files to your folder on your webspace and navigate to it!</p>
<p><a class="example_but demo" href="http://youngdutchdesign.com/examples/moodrop.php">Example</a> <a class="example_but download" href="http://youngdutchdesign.com/examples/js/moodrop.js">Download Class</a> <a class="example_but zipfile" href="http://www.youngdutchdesign.com/downloads/cvMooDrop_examples.zip">Download Zip</a></p>
<p><span id="more-1595"></span></p>
<h2>File structure</h2>
<p>The following structure is used in the example and the documentation.</p>
<ul>
<li><strong>images</strong>
<ul>
<li>your_image.jpg</li>
</ul>
</li>
<li><strong>js</strong>
<ul>
<li>cvMooDrop.js</li>
<li>mootools-1.2.js</li>
</ul>
</li>
<li>ajax_moodrop.php</li>
<li>basic.css</li>
<li>cvMooDrop.css</li>
<li>index.php /*This file contains the html for the eyedropper*/</li>
<li>moodrop.php</li>
</ul>
<h2>The html</h2>
<p>The html is really simple. The path to the image is the relative path.</p>
<h2>The css</h2>
<pre class="css">#dropperid {
	float: left;
	padding: 0px;
	width: 551px; //the width of the image
	height: 157px; //the height of the image
	}

#prev {
	float: left;
	width: 80px;
	height: 80px;
	border: 1px #CCC solid;
	}</pre>
<h2>The basic javascript</h2>
<pre class="javascript">window.addEvent('domready', function() {
	var test1 = new moodrop('dropperid',{
		url: 'ajax_moodrop.php',
		prev_id: 'prev'
	});
});</pre>
<h2>The more advanced javascript</h2>
<pre class="javascript">window.addEvent('domready', function() {
	var test2 = new moodrop('dropperadvanced',{
		url: 'ajax_moodrop.php',
		prev_id: 'prev2',
	});

	var colors = [];

	var addColor = function(c){
		if(colors.contains(c)){
			alert('This color already exists!');
		}else{
			colors.push(c);
			$('colors_field').value = JSON.encode(colors);
			createColor(c);
		}
	}

	var createColor = function(c){
		var box = new Element('span',{	'id': this.hex,
							  			'class': 'box',
										'styles': {
											'background': c,
											'display': 'block',
											'float': 'left',
											'cursor': 'pointer'
											}
										}).inject($('scheme'));
	};

	$('add').addEvent('click',function(a){
		addColor(test2.hex);
	});
});</pre>
<h2>The php (ajax_moodrop.php)</h2>
<p>The AJAX request has several variables in it to get the right pixel, the pixel the dropper is pointing at.</p>
<ul>
<li><strong>image: </strong>the relative path to the image file</li>
<li><strong>n: </strong>the relative top position of the pixel</li>
<li><strong>w: </strong>the relative left position of the pixel</li>
</ul>
<pre class="php">if(isset($_GET['image'])){
	/* select the left lower pixel from the dropperdiv and get the color index */
	$im = imagecreatefromjpeg($_GET['image']);
	$color_index = imagecolorat($im, $_GET['w'], $_GET['n']);

	/* get rid of the temporary image and display the human readable hex color */
	echo '#'.dechex($color_index);
}</pre>
<p>The function imagecreatefrom* can be changed to several functions, depending on the image type you use. In this case I&#8217;ve used a very simple static solution but you can select the correct function by checking the mime type.</p>
<ul>
<li><a href="http://php.net/imagecreatefromjpeg" target="_blank">imagecreatefromjpeg</a></li>
<li><a href="http://php.net/imagecreatefromgif" target="_blank">imagecreatefromgif</a></li>
<li><a href="http://php.net/imagecreatefrompng" target="_blank">imagecreatefrompng</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/moodrop-mootools-eyedropper-tool/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Verot.net Upload Class</title>
		<link>http://youngdutchdesign.com/verot-net-upload-class</link>
		<comments>http://youngdutchdesign.com/verot-net-upload-class#comments</comments>
		<pubDate>Wed, 23 Sep 2009 17:46:22 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Webdesign]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=1602</guid>
		<description><![CDATA[This time not a very new cool and flashy gadget but a very solid upload class that maybe end one of your worst long nightmares &#8211; File uploading and image resizing, cropping and styling. Besides uploading images you can upload all the files that you want, as long you add them to the safe list. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1603" title="upload" src="http://youngdutchdesign.com/wp-content/uploads/2009/09/upload.jpg" alt="upload" width="190" height="197" />This time not a very new cool and flashy gadget but a very solid upload class that maybe end one of your worst long nightmares &#8211; File uploading and image resizing, cropping and styling.</p>
<p>Besides uploading images you can upload all the files that you want, as long you add them to the safe list.</p>
<ul>
<li><a href="http://www.verot.net/php_class_upload_samples.htm" target="_blank">Samples</a></li>
<li><a href="http://www.verot.net/res/sources/class.upload.html" target="_blank">Documentation</a></li>
<li><a href="http://www.verot.net/php_class_upload_download.htm" target="_blank">Download</a></li>
</ul>
<p>Try it out and you&#8217;ll be convinced! More cool stuff based on this script will be shown in the near future!</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/verot-net-upload-class/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linebreaks with PHP_EOL</title>
		<link>http://youngdutchdesign.com/linebreaks-with-phpeol</link>
		<comments>http://youngdutchdesign.com/linebreaks-with-phpeol#comments</comments>
		<pubDate>Mon, 25 May 2009 20:03:50 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Starting with php]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=1468</guid>
		<description><![CDATA[There are several ways to make your source code readable. echo "Hello World\n"; //or echo "Hello World\r"; //or echo "Hello World\r\n"; But I don&#8217;t like the double quote&#8217;s in this notation because when I&#8217;m echo html tags into it, I&#8217;ll have to escape allt he double quotes. This is why I prefer the following usage. [...]]]></description>
			<content:encoded><![CDATA[<p>There are several ways to make your source code readable.</p>
<pre class="php">
echo "Hello World\n";
//or
echo "Hello World\r";
//or
echo "Hello World\r\n";
</pre>
<p>But I don&#8217;t like the double quote&#8217;s in this notation because when I&#8217;m echo html tags into it, I&#8217;ll have to escape allt he double quotes. This is why I prefer the following usage.</p>
<pre class="php">echo 'Hello World!'.PHP_EOL;</pre>
<p class="note">EOL stands for End of Line. </p>
<p>Sometimes the server is running on windows and the EOL tag is  this define tag by default. This is the point where a simple hack comes in&#8230;</p>
<p><span id="more-1468"></span><br />
Just put the following line on top of your script:</p>
<pre class="php">
if(!defined('PHP_EOL')){
	define('PHP_EOL', strtoupper(substr(PHP_OS,0,3) == 'WIN') ? "\r\n" : "\n");
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/linebreaks-with-phpeol/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regular Expression Testing Tool</title>
		<link>http://youngdutchdesign.com/regular-expression-testing-tool</link>
		<comments>http://youngdutchdesign.com/regular-expression-testing-tool#comments</comments>
		<pubDate>Sun, 24 May 2009 09:03:48 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Starting with php]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=1460</guid>
		<description><![CDATA[If you&#8217;re struggeling with regular Expressions I have a great tip for you. Just go to the website RegExr: Online Regular Expression Testing and put your regular expression together!]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re struggeling with regular Expressions I have a great tip for you. Just go to the website <a href="http://www.gskinner.com/RegExr/" target="_blank">RegExr: Online Regular Expression Testing</a> and put your regular expression together!</p>
<p><img class="alignnone size-full wp-image-1463" title="screenshot138" src="http://youngdutchdesign.com/wp-content/uploads/2009/05/screenshot138.jpeg" alt="screenshot138" width="600" height="388" /></p>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/regular-expression-testing-tool/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic subdomains using php</title>
		<link>http://youngdutchdesign.com/dyami-subdomains-using-php</link>
		<comments>http://youngdutchdesign.com/dyami-subdomains-using-php#comments</comments>
		<pubDate>Wed, 06 May 2009 11:37:25 +0000</pubDate>
		<dc:creator>Crispijn</dc:creator>
				<category><![CDATA[Webdesign]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://youngdutchdesign.com/?p=1231</guid>
		<description><![CDATA[There are several cases when you would like to use dynamic subdomains. In case your webhosting don&#8217;t support unlimited subdomains or when you&#8217;re developing a community website with a focus on the user profiles. In this case I recommend you to write a script which allows users to create personal pages with a clear address [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1232" title="apache" src="http://youngdutchdesign.com/wp-content/uploads/2009/04/apache.png" alt="apache" width="200" height="178" />There are several cases when you would like to use dynamic subdomains. In case your webhosting don&#8217;t support unlimited subdomains or when you&#8217;re developing a community website with a focus on the user profiles. In this case I recommend you to write a script which allows users to create personal pages with a clear address like &#8216;crispijn.yourdomain.com&#8217;.</p>
<p>Obviously do I know the .htaccess solution to create subdomains. This is very handy if you don&#8217;t have cPanel or another web admin tool.</p>
<pre class="html">RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.yoursite\.com
RewriteCond %{HTTP_HOST} ([^.]+)\.yoursite\.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/%1 [L,R]</pre>
<p>This solution points to a folder in your root so it isn&#8217;t a very dynamic one. Lets see <strong>the </strong>solution!</p>
<p><span id="more-1231"></span></p>
<h2>Apache configuration</h2>
<p>First you have to change the Apache configuration to make it by adding the following line to the httppd.conf file (the Apache configuration file).</p>
<pre class="php">ServerAlias *.yourdomain.com</pre>
<p>Read more about this configuration on the <a href="http://httpd.apache.org/docs/2.2/" target="_blank">Apache website.</a></p>
<h2>Static subdomains</h2>
<pre class="php">//array for static subdomains
$subdomains = array(
			'forum',
			'mobile',
			'demos',
			);

$match = preg_replace('#(http://)?(www\.)?(.+?)(\.yourdomain.com){1}#i','\\3', $_SERVER['HTTP_HOST']);

	if(in_array($match, $subdomains)){
		include('/root/yourdomain.com/'.$matc.'/index.php');
	}else{
		//Do normal stuff
	}</pre>
<h2>Dynamic sub domains</h2>
<p>It is also possible to create the array from a database selection. See the following example:</p>
<pre class="php">//array for static subdomains
$subdomains = array(
			'forum',
			'mobile',
			'demos',
			);

$match = preg_replace('#(http://)?(www\.)?(.+?)(\.yourdomain.com){1}#i','\\3', $_SERVER['HTTP_HOST']);

	if(in_array($match, $subdomains)){
		include('/root/yourdomain.com/'.$matc.'/index.php');
	}else{
		$sql = "SELECT nickname FROM users WHERE nickname = ".$match;
		$res = mysql_query($sql);
		$rows = mysql_num_rows($res);

		if($rows == 1){
			//pointer to user profile page
			include('/root/yourdomain.com/profiles/index.php);
		}else{
			//Do normall stuff
		}
	}</pre>
<p><strong>NOTE!</strong><br />
<em>This is a very basic way of creating subdomains. There are no build in checks or errorhandler. The way of naming your files and choosing a structure is whole yours.</em></p>
<h2>Sessions</h2>
<p>When you&#8217;re using sessions (a login system for example) the session will be lost you&#8217;re browsing to another (sub)domain. You can prevent this by adding the following line to your .htaccess file in the root of your site.</p>
<pre class="html">session.cookie_domain = "yourdomain.com"</pre>
]]></content:encoded>
			<wfw:commentRss>http://youngdutchdesign.com/dyami-subdomains-using-php/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
