<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>IndividualWeb</title>
	<atom:link href="http://individualweb.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://individualweb.wordpress.com</link>
	<description>Let&#039;s become great programmers together!</description>
	<lastBuildDate>Wed, 14 Dec 2011 09:37:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='individualweb.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>IndividualWeb</title>
		<link>http://individualweb.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://individualweb.wordpress.com/osd.xml" title="IndividualWeb" />
	<atom:link rel='hub' href='http://individualweb.wordpress.com/?pushpress=hub'/>
		<item>
		<title>The evolution of how I code common objects</title>
		<link>http://individualweb.wordpress.com/2011/11/20/the-evolution-of-how-i-code-common-objects/</link>
		<comments>http://individualweb.wordpress.com/2011/11/20/the-evolution-of-how-i-code-common-objects/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 10:48:35 +0000</pubDate>
		<dc:creator>individualweb</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[Objects]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Syntax]]></category>

		<guid isPermaLink="false">http://individualweb.wordpress.com/?p=253</guid>
		<description><![CDATA[I always try to make my code as small as possible, as long as it is understandable to a degree &#8211; and simple code is for me often that. DRY is a good rule, sometimes hard to figure out how to not repeat myself, but sometimes I discover good techniques. In my early programming days, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=253&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I always try to make my code as small as possible, as long as it is understandable to a degree &#8211; and simple code is for me often that. DRY is a good rule, sometimes hard to figure out how to not repeat myself, but sometimes I discover good techniques. </p>
<p>In my early programming days, in the case of objects, I always made every object like this:</p>
<pre style="font-size:130%;border:1px solid #ddd;padding:8px;">
class Student {
   private $name;
   private $address;

   public function __construct($name, $address){
      $this-&gt;setName($name);
      $this-&gt;setAddress($address);
   }

   public function setName($name){
      $this-&gt;name = $name;
   }
   public function getName(){
      return $this-&gt;name;
   }
   public function setAddress($address){
      $this-&gt;address = $address;
   }
   public function getAddress(){
      return $this-&gt;address;
   }
}

$student = new Student();
$student-&gt;SetName('John');
echo $student-&gt;GetName();
</pre>
<p>Then I discovered that I don&#8217;t need to have a getter and setter for every property, I wanted to get rid of them and it could be done like this:</p>
<pre style="font-size:130%;border:1px solid #ddd;padding:8px;">
class Student {
   private $name;
   private $address;

   public function __construct($name, $address){
      $this-&gt;Name($name);
      $this-&gt;Address($address);
   }

   public function Name($name=null){
      if($name===null){
         return $this-&gt;name;
      }
      $this-&gt;name = $name;
   }
   public function Address($address=null){
      if($address===null){
         return $this-&gt;address;
      }
      $this-&gt;address = $address;
   }
}

$student = new Student();
$student-&gt;Name('John');
echo $student-&gt;Name();
</pre>
<p>Notice, that the use of null here do that you cannot use null as a value to a property, but the properties are null if you get them and they are not set. Anyways, this became all too much code when you got like 10+ objects with 10+ properties each, repeating the syntax for every property. So I turned into something like this:</p>
<pre style="font-size:130%;border:1px solid #ddd;padding:8px;">
class Student {
   private $name;
   private $address;

   public function __construct($name, $address){
      $this-&gt;Name($name);
      $this-&gt;Address($address);
   }

   public function set_get($property, $value=null){
      if($value===null){
         return $this-&gt;$property;
      }
      $this-&gt;$property = $value;
   }

   public function Name($name=null){
      $this-&gt;set_get('name', $name);
   }
   public function Address($address=null){
      $this-&gt;set_get('address', $address);
   }
}

$student = new Student();
$student-&gt;Name('John');
echo $student-&gt;Name();
</pre>
<p>But why do one have to go through a method for each property? we can easily get rid of all that by simply using the set &amp; get and then use an array as the property holder.</p>
<pre style="font-size:130%;border:1px solid #ddd;padding:8px;">
class Student {
   private $properties = array();

   public function set($property, $value){
      $this-&gt;properties[$property] = $value;
   }
   public function get($property){
      return (isset($this-&gt;properties[$property])
              ?$this-&gt;properties[$property]
              :false;
   }
}

$student = new Student();
$student-&gt;set('name', 'John');
echo $student-&gt;get('name');
</pre>
<p>Less code, easy to maintain, only drawback is to make som additional actions in every set/get, something that I seldom do anyways. Also, every set/get does not turn up in the list of methods that Eclipse/NetBeans find. If needed those can get own methods. Still, this is all too much for every single class when the code is the same on many &#8211; it is better to extend a class that has that code:</p>
<pre style="font-size:130%;border:1px solid #ddd;padding:8px;">
class Master {
   private $properties = array();

   public function set($property, $value){
      $this-&gt;properties[$property] = $value;
   }
   public function get($property){
      return (isset($this-&gt;properties[$property])
              ?$this-&gt;properties[$property]
              :false;
   }
}

class Student extends Master {}

$student = new Student();
$student-&gt;set('name', 'John');
echo $student-&gt;get('name');
</pre>
<p>This way every object get the same functionality and only one line is required to make one object. But why not go even further. Both in how values are set and get, and how classes are created. PHP has this magic function called __autoload(), and including this inside it make it so that any class can be created even if it does not exist:</p>
<pre style="font-size:130%;border:1px solid #ddd;padding:8px;">
class Master {
   private $properties = array();
   public function val($prop, $val=null){
      if($val===null){
         return (isset($this-&gt;properties[$prop])
                 ?$this-&gt;properties[$prop]
                 :false);
      }
      $this-&gt;properties[$prop] = $val;
   }
}
function __autoload($class) {
   eval('class '.$class.' extends Master {}');
}

$student = new Student();
$student-&gt;val('name', 'John');
echo $student-&gt;val('name');
</pre>
<p>Now I can create any object with any name on the fly. It is like a stdClass, but with functionality and not anonymous. But isn&#8217;t the use of eval like&#8230; evil? Well, typically it should be avoided, especially if the content you put in is user-generated from a form. If this is the case, you have to strip away everything from the class name that does not belong in a class name before you evaluate it. Don&#8217;t do it if you don&#8217;t know what you are doing. There are some more stuff I want to do with this:</p>
<pre style="font-size:130%;border:1px solid #ddd;padding:8px;">
class Master {
   private $props = array();
   public function val($prop, $val=null){
      if($val===null){
         return (isset($this-&gt;props[$prop])
                 ?$this-&gt;props[$prop]
                 :false);
      }
      $this-&gt;props[$prop] = $val;
      return $this;
   }
}
function __autoload($class) {
   eval('class '.$class.' extends Master {}');
}
function obj($name){
   return new $name();
}

echo obj('Student')-&gt;val('name', 'John')-&gt;val('name');
</pre>
<p>Like that! Now I don&#8217;t have to initiate a new object every time I want to make one, and I added chaining so that every value can be set more fluid. All of the code above is only a starting point, and need additional stuff to make them robust, secure, and stuff like that. I hope you get the idea, because in many projects it is unnecessary and dull to create bloated objects for every simple type of class you want to use. In more complex projects you may need to skip some of the simplifications, to get more flexibility in functionality for each class.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/individualweb.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/individualweb.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/individualweb.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/individualweb.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/individualweb.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/individualweb.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/individualweb.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/individualweb.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/individualweb.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/individualweb.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/individualweb.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/individualweb.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/individualweb.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/individualweb.wordpress.com/253/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=253&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://individualweb.wordpress.com/2011/11/20/the-evolution-of-how-i-code-common-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9bbab75734efe135a56b332b7f9c00f6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">individualweb</media:title>
		</media:content>
	</item>
		<item>
		<title>Debug slow code with ticks</title>
		<link>http://individualweb.wordpress.com/2011/10/24/debug-slow-code-with-ticks/</link>
		<comments>http://individualweb.wordpress.com/2011/10/24/debug-slow-code-with-ticks/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 17:28:37 +0000</pubDate>
		<dc:creator>individualweb</dc:creator>
				<category><![CDATA[Debug]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Singleton]]></category>

		<guid isPermaLink="false">http://individualweb.wordpress.com/?p=232</guid>
		<description><![CDATA[I made this small snippet of code today, using my style of coding with a singleton class wrapped into a function. The idea is to time the differents parts of the code to find where the code is slowest, and thus, where to improve and optimize. The way you use the code is like this: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=232&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I made this small snippet of code today, using my style of coding with a singleton class wrapped into a function. The idea is to time the differents parts of the code to find where the code is slowest, and thus, where to improve and optimize. The way you use the code is like this:</p>
<pre style="font-size:130%;border:1px solid #ddd;padding:8px;">
tick('Initialize');
/* CODE TO TEST */
tick('Code snippet one');
/* CODE TO TEST */
tick('Code snippet two');
tick()-&gt;show();
</pre>
<p>This will echo something like:</p>
<p>Msg: Initialize<br />
Msg: Code snippet one<br />
Time: 3.543 sec<br />
Msg: Code snippet two<br />
Time: 1.002 sec</p>
<p>Here is the full code:</p>
<pre style="font-size:130%;border:1px solid #ddd;padding:8px;">
function tick($msg = ''){
    $instance = ticks::inst();
    if($msg != ''){
        $instance-&gt;tick($msg);
    }
    return $instance;
}

class ticks {
    private $tick = array();
    private static $instance;

    public static function inst(){
        if(!isset(self::$instance)){
            self::$instance = new self();
        }
        return self::$instance;
    }

    public function tick($msg=''){
        $time = (string)microtime(true);
        $this-&gt;tick[$time] = $msg;
    }

    public function show(){
        $last = 0;
        foreach($this-&gt;tick as $time =&gt; $msg){
            $time = (float)$time;
            echo 'Msg: "'.$msg.'"';
            if($last_time != 0){
                $sec = round($time-$last, 3);
                echo 'Time: "'.$sec.' sec"';
            }
            $last = $time;
        }
    }
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/individualweb.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/individualweb.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/individualweb.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/individualweb.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/individualweb.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/individualweb.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/individualweb.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/individualweb.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/individualweb.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/individualweb.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/individualweb.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/individualweb.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/individualweb.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/individualweb.wordpress.com/232/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=232&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://individualweb.wordpress.com/2011/10/24/debug-slow-code-with-ticks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9bbab75734efe135a56b332b7f9c00f6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">individualweb</media:title>
		</media:content>
	</item>
		<item>
		<title>A tip when you are stuck</title>
		<link>http://individualweb.wordpress.com/2011/06/20/a-tip-when-you-are-stuck/</link>
		<comments>http://individualweb.wordpress.com/2011/06/20/a-tip-when-you-are-stuck/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 14:59:02 +0000</pubDate>
		<dc:creator>individualweb</dc:creator>
				<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[Debug]]></category>

		<guid isPermaLink="false">http://individualweb.wordpress.com/?p=224</guid>
		<description><![CDATA[The other day at work I was making this algorithm, but did not get it to work. It looked so simple, but it was not &#8211; so I worked with it for a few hours without result. When I took the time of for a few days, and decided to look at the problem again [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=224&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The other day at work I was making this algorithm, but did not get it to work. It looked so simple, but it was not &#8211; so I worked with it for a few hours without result. </p>
<p>When I took the time of for a few days, and decided to look at the problem again I fixed it in a few minutes. It was not a perfect fix, but as good as.</p>
<p>So, the tip when you are stuck:</p>
<p>Take some days off, and think of other things, and when you are back you may se an easy solution.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/individualweb.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/individualweb.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/individualweb.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/individualweb.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/individualweb.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/individualweb.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/individualweb.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/individualweb.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/individualweb.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/individualweb.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/individualweb.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/individualweb.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/individualweb.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/individualweb.wordpress.com/224/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=224&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://individualweb.wordpress.com/2011/06/20/a-tip-when-you-are-stuck/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9bbab75734efe135a56b332b7f9c00f6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">individualweb</media:title>
		</media:content>
	</item>
		<item>
		<title>PHP $_GET in JavaScript</title>
		<link>http://individualweb.wordpress.com/2011/06/15/php-_get-in-javascript/</link>
		<comments>http://individualweb.wordpress.com/2011/06/15/php-_get-in-javascript/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 11:06:03 +0000</pubDate>
		<dc:creator>individualweb</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://individualweb.wordpress.com/?p=218</guid>
		<description><![CDATA[This other day I encountered a situation where I needed to pass in variables to a javascript. I had built the javascript in a PHP file before, and could easily use PHP to inject the variables like this: var name = "&#60;?php echo $name ?&#62;" But when I wanted to separate the javascript from PHP [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=218&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This other day I encountered a situation where I needed to pass in variables to a javascript. I had built the javascript in a PHP file before, and could easily use PHP to inject the variables like this:</p>
<p><code>var name = "&lt;?php echo $name ?&gt;"</code></p>
<p>But when I wanted to separate the javascript from PHP I could not access the PHP variables anymore, the solution was to do it like this:</p>
<p>&lt;script src=&#8221;my_script.js?name=&lt;?php echo $name ?&gt;&#8221; &gt;&lt;/script &gt;</p>
<p>and then access the variable from the script by $_GET.name</p>
<p>The code on jsfiddle:<br />
<a href="http://jsfiddle.net/ctncP/">http://jsfiddle.net/ctncP/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/individualweb.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/individualweb.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/individualweb.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/individualweb.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/individualweb.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/individualweb.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/individualweb.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/individualweb.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/individualweb.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/individualweb.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/individualweb.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/individualweb.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/individualweb.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/individualweb.wordpress.com/218/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=218&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://individualweb.wordpress.com/2011/06/15/php-_get-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9bbab75734efe135a56b332b7f9c00f6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">individualweb</media:title>
		</media:content>
	</item>
		<item>
		<title>A better way to organize localhost</title>
		<link>http://individualweb.wordpress.com/2011/06/12/a-better-way-to-organize-localhost/</link>
		<comments>http://individualweb.wordpress.com/2011/06/12/a-better-way-to-organize-localhost/#comments</comments>
		<pubDate>Sun, 12 Jun 2011 01:03:49 +0000</pubDate>
		<dc:creator>individualweb</dc:creator>
				<category><![CDATA[Organizing]]></category>
		<category><![CDATA[Server]]></category>

		<guid isPermaLink="false">http://individualweb.wordpress.com/?p=203</guid>
		<description><![CDATA[I have a lot of projects going on, and I&#8217;m doing them all on my home computer, using a xampp server @ locaholst. Since I have a lot of projects, the folder structure is like this: c:\xampp\htdocs\project1 =&#62; http://localhost/project1 c:\xampp\htdocs\project2 =&#62; http://localhost/project2 etc. The problem was that when the sites goes live, they are like: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=203&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have a lot of projects going on, and I&#8217;m doing them all on my home computer, using a xampp server @ locaholst.</p>
<p>Since I have a lot of projects, the folder structure is like this:</p>
<p>c:\xampp\htdocs\project1 =&gt; http://localhost/project1<br />
c:\xampp\htdocs\project2 =&gt; http://localhost/project2<br />
etc.</p>
<p>The problem was that when the sites goes live, they are like:</p>
<p>http://localhost/project1 =&gt; http://project1.com<br />
http://localhost/project2 =&gt; http://project2.com<br />
etc.</p>
<p>This is messed up my code because the root folder changed. On localhost, the root folder is http://localhost/ and the projects are inside subfolders. My solution was for a long time to have a method named getRoot() that returned /projectX/ subfolder as root when localhost and / as root on live server. But I had to use this method every single time I make a link. This is not really a problem until you start making URLs pretty, and some other occasions.</p>
<p>Well, then, one bright and sunny day I though, why am I doing this? Shouldn&#8217;t there be an easier way? And of course there was &#8211; I just never really bothered to check.</p>
<p>Add lines into c:/windows/system32/drivers/etc/hosts file:</p>
<p>127.0.0.1 project1.local<br />
127.0.0.1 project2.local</p>
<p>And then configure your local httpd.conf file, with adding the lines and restarting apache:<br />
&lt;VirtualHost *:80&gt;<br />
 ServerName project1.local<br />
 DocumentRoot &#8220;c:/xampp/htdocs/project1&#8243;<br />
 DirectoryIndex index.php index.html index.html index.htm index.shtml<br />
&lt;/VirtualHost&gt;<br />
&lt;VirtualHost *:80&gt;<br />
 ServerName project2.local<br />
 DocumentRoot &#8220;c:/xampp/htdocs/project2&#8243;<br />
 DirectoryIndex index.php index.html index.html index.htm index.shtml<br />
&lt;/VirtualHost&gt;</p>
<p>Now, when you want to test your site locally, you can use the addresses:</p>
<p>http://project1.local and http://project2.local</p>
<p>You don&#8217;t need to have your site inside c:/xampp/htdocs/ anymore either, by changing the VirtualHost configuration you can easily put them into c:/web/ or a folder of your choice.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/individualweb.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/individualweb.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/individualweb.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/individualweb.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/individualweb.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/individualweb.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/individualweb.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/individualweb.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/individualweb.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/individualweb.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/individualweb.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/individualweb.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/individualweb.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/individualweb.wordpress.com/203/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=203&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://individualweb.wordpress.com/2011/06/12/a-better-way-to-organize-localhost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9bbab75734efe135a56b332b7f9c00f6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">individualweb</media:title>
		</media:content>
	</item>
		<item>
		<title>The curious case of a textarea</title>
		<link>http://individualweb.wordpress.com/2011/05/19/the-curious-case-of-a-textarea/</link>
		<comments>http://individualweb.wordpress.com/2011/05/19/the-curious-case-of-a-textarea/#comments</comments>
		<pubDate>Thu, 19 May 2011 18:25:19 +0000</pubDate>
		<dc:creator>individualweb</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://individualweb.wordpress.com/?p=204</guid>
		<description><![CDATA[I came across this little problem today, where I wanted the modified content of a textarea. This is the textarea: &#60;textarea id="area"&#62;Some text&#60;/textarea&#62; I wanted to edit it, and then alert the result. But guess what, the alerted text said &#8220;Some text&#8221; and not &#8220;Edited text&#8221; The following code was tried: alert($('#area').text()); alert($('#area').html()); alert(document.getElementById('area').innerHTML); The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=204&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I came across this little problem today, where I wanted the modified content of a textarea.</p>
<p>This is the textarea:</p>
<p><code>&lt;textarea id="area"&gt;Some text&lt;/textarea&gt;</code></p>
<p>I wanted to edit it, and then alert the result. But guess what, the alerted text said &#8220;Some text&#8221; and not &#8220;Edited text&#8221;</p>
<p>The following code was tried:</p>
<p><code>alert($('#area').text());</code><br />
<code>alert($('#area').html());</code><br />
<code>alert(document.getElementById('area').innerHTML);</code></p>
<p>The answer was really simple after some minutes of trying, but the question why still remains. </p>
<p>This does the trick:</p>
<p><code>alert(document.getElementById('area').value);</code><br />
<code>alert($('#area').val());</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/individualweb.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/individualweb.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/individualweb.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/individualweb.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/individualweb.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/individualweb.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/individualweb.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/individualweb.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/individualweb.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/individualweb.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/individualweb.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/individualweb.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/individualweb.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/individualweb.wordpress.com/204/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=204&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://individualweb.wordpress.com/2011/05/19/the-curious-case-of-a-textarea/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9bbab75734efe135a56b332b7f9c00f6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">individualweb</media:title>
		</media:content>
	</item>
		<item>
		<title>try to catch this if else</title>
		<link>http://individualweb.wordpress.com/2011/05/01/try-to-catch-this-if-else/</link>
		<comments>http://individualweb.wordpress.com/2011/05/01/try-to-catch-this-if-else/#comments</comments>
		<pubDate>Sun, 01 May 2011 20:04:35 +0000</pubDate>
		<dc:creator>individualweb</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Syntax]]></category>

		<guid isPermaLink="false">http://individualweb.wordpress.com/?p=190</guid>
		<description><![CDATA[How should you write &#8220;try catch&#8221; and &#8220;if else&#8221;? I&#8217;ve seen a lot of this: if() { } else { } try { } catch { } But it really should be like: if() { } else { } try { } catch { } Why? It&#8217;s really a little detail, but in the first [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=190&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>How should you write &#8220;try catch&#8221; and &#8220;if else&#8221;?</p>
<p>I&#8217;ve seen a lot of this:</p>
<p><code>if() {<br />
}<br />
else {<br />
}</p>
<p>try {<br />
}<br />
catch {<br />
}<br />
</code></p>
<p>But it really should be like:</p>
<p><code>if() {<br />
} else {<br />
}</p>
<p>try {<br />
} catch {<br />
}<br />
</code></p>
<p>Why? It&#8217;s really a little detail, but in the first examples it looks like you could add code between the try and the catch, because they are two blocks of code. But the catch belongs to the try, so it should not be seperated by a new line. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/individualweb.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/individualweb.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/individualweb.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/individualweb.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/individualweb.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/individualweb.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/individualweb.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/individualweb.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/individualweb.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/individualweb.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/individualweb.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/individualweb.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/individualweb.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/individualweb.wordpress.com/190/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=190&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://individualweb.wordpress.com/2011/05/01/try-to-catch-this-if-else/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9bbab75734efe135a56b332b7f9c00f6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">individualweb</media:title>
		</media:content>
	</item>
		<item>
		<title>Thoughts about __toString() in PHP</title>
		<link>http://individualweb.wordpress.com/2011/03/23/thoughts-about-__tostring-in-php/</link>
		<comments>http://individualweb.wordpress.com/2011/03/23/thoughts-about-__tostring-in-php/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 20:42:22 +0000</pubDate>
		<dc:creator>individualweb</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://individualweb.wordpress.com/?p=168</guid>
		<description><![CDATA[PHP is a loosely typed language(the same variable can be a string or number), but sometimes I think it should be even more loose in some aspects and allow even more magic. Maybe that was a wrong way of putting it, but especially in the case of __toString() in PHP I think that the developers [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=168&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>PHP is a loosely typed language(the same variable can be a string or number), but sometimes I think it should be even more loose in some aspects and allow even more magic. Maybe that was a wrong way of putting it, but especially in the case of __toString() in PHP I think that the developers copied Java without thinking the possibilities of the method, what it could have been if it was not bound to &#8220;String&#8221;. &#8220;String&#8221; is this old thing, actually one of the first things, that was created out of 0 and 1.</p>
<p>If you&#8217;re not familiar with __toString() method, I&#8217;ll first explain what it does. The __ tells you that this is a magic method, and it is a feature provided in an object in PHP and many other languages. The point of __toString() is to return a string value of the object if it is in a string context, or simply put, echoed. Example:</p>
<p><code><br />
class Person {<br />
private $fname = 'John';<br />
private $lname = 'Doe';<br />
public function __toString(){<br />
return $this-&gt;fname.' '.$this-&gt;lname;<br />
}<br />
}</p>
<p>$person = new Person();<br />
echo $person; //John Doe<br />
</code></p>
<p>For me this gives my object a new dimension. My Object is a string and an object. And I&#8217;m mostly fine with it, more than that, I love the feature.</p>
<p>What I would like to change is to change the __toString() method into __toValue(), or add more functions like __toArray() and __toObject() or __toWhatever() that can be used if the __toString is not set or/and in a prioritized order(I say if the __toString() is not set, because it should not be deprecated at first).</p>
<p>Let&#8217;s make __toArray() the example. I would like my object to be interpreted as an array in some cases if the object way is not supported. The best way to show what I mean is to use an example:</p>
<p><code><br />
class Person {<br />
private $fname = 'John';<br />
private $lname = 'Doe';<br />
public function __toArray(){<br />
return array('fname'=&gt;$this-&gt;fname, 'lname'=&gt;$this-&gt;lname);<br />
}<br />
}<br />
$person = new Person();<br />
//NOT VALID PHP<br />
echo $person['fname']; //John<br />
</code><code><br />
//VALID PHP<br />
$person = $person-&gt;__toArray();<br />
echo $person['fname']; //John<br />
</code></p>
<p>As you can see, the idea is likeable &#8211; and I&#8217;m not the first one to propose the add-on. But why do I like this?<br />
- Because it gives an Object more functionality<br />
- You can do much more cool stuff without having to create and call functions for them<br />
- Gives objects multiple dimensions, and makes them more rich<br />
- Cool if you need to transform an Object into different types of structures and easily append into different situations<br />
- You could use an Object in new places, like directly in a foreach loop<br />
- Why should this only work with strings?<br />
- Can give access to private and protected values of the object where casting((array)Object) does not work<br />
- __toString() is actually faster than calling a public method toString() that does the same.<br />
- Great way of simplifying some frameworks<br />
- __toString() limits the use of something that should not be limited in my opinion </p>
<p>Why not?<br />
- It&#8217;s not that hard to make an own toArray() method that does the magic without being magic<br />
- Magic methods may add some more &#8220;WTF?&#8221; to some programmers<br />
- (whispering carefully from a corner)We should not use magic methods that much? (Why not?)</p>
<p>Well, I really can&#8217;t think of many bad things with some extra magic. Are there other arguments for or against?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/individualweb.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/individualweb.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/individualweb.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/individualweb.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/individualweb.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/individualweb.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/individualweb.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/individualweb.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/individualweb.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/individualweb.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/individualweb.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/individualweb.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/individualweb.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/individualweb.wordpress.com/168/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=168&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://individualweb.wordpress.com/2011/03/23/thoughts-about-__tostring-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9bbab75734efe135a56b332b7f9c00f6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">individualweb</media:title>
		</media:content>
	</item>
		<item>
		<title>Ideas of March.</title>
		<link>http://individualweb.wordpress.com/2011/03/19/ideas-of-march/</link>
		<comments>http://individualweb.wordpress.com/2011/03/19/ideas-of-march/#comments</comments>
		<pubDate>Sat, 19 Mar 2011 15:08:33 +0000</pubDate>
		<dc:creator>individualweb</dc:creator>
				<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://individualweb.wordpress.com/?p=132</guid>
		<description><![CDATA[Oh blogging, oh blogging. Thy threshold is low, but the maintenance is big. I like reading blogs. Especially those that have categories and tags to filter out all the stuff you don&#8217;t want to read about. The only thing that bothers me is that you often have to read a lot of blogs to find [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=132&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Oh blogging, oh blogging. Thy threshold is low, but the maintenance is big.</p>
<p>I like reading blogs. Especially those that have categories and tags to filter out all the stuff you don&#8217;t want to read about. The only thing that bothers me is that you often have to read a lot of blogs to find updated material on the things I care about, especially in the PHP community. Great post should be advertised and marked cool! If only the people who do have some cool code to provide could blog more frequent with a lot of cool code!! Sigh.</p>
<p>It&#8217;s a challenge. I know that, having some blogs out there with different kinds of content, updated every now and then. Blogging takes time if you want to do it good. People want an updated blog. Blogs does not bring that big of an income. But still, people keep blogging, I keep blogging, and you keep blogging. Every once and then someone finds your post in a time of need, and the purpose of the post is fulfilled. Do not blog for the masses, blog for the few that can evolve into masses. Blog for yourself. Blog to make a history, if only your own blogging history! That is a best practice!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/individualweb.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/individualweb.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/individualweb.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/individualweb.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/individualweb.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/individualweb.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/individualweb.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/individualweb.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/individualweb.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/individualweb.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/individualweb.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/individualweb.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/individualweb.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/individualweb.wordpress.com/132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=132&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://individualweb.wordpress.com/2011/03/19/ideas-of-march/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9bbab75734efe135a56b332b7f9c00f6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">individualweb</media:title>
		</media:content>
	</item>
		<item>
		<title>Send large emails in php</title>
		<link>http://individualweb.wordpress.com/2011/03/17/send-large-emails-in-php/</link>
		<comments>http://individualweb.wordpress.com/2011/03/17/send-large-emails-in-php/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 10:51:52 +0000</pubDate>
		<dc:creator>individualweb</dc:creator>
				<category><![CDATA[Debug]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://individualweb.wordpress.com/?p=154</guid>
		<description><![CDATA[I&#8217;ve encountered this problem once a long time ago, and used a lot of time finding a solution back then. Probably because no one really directly issued this problem. When you send large text in your mail, specially HTML, you have to remember to encode the message right and chunk it. Why? The email standard [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=154&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve encountered this problem once a long time ago, and used a lot of time finding a solution back then. Probably because no one really directly issued this problem.</p>
<p>When you send large text in your mail, specially HTML, you have to remember to encode the message right and chunk it. Why? The email standard <a href="http://www.faqs.org/rfcs/rfc2822.html">RFC2822</a> only accepts line lengths of 998 chars, and if you send longer lines you probably encounter a lot of problems in different email clients. This may be line breaks or spaces after every chunk of 998 chars, that could be in the middle of an HTML tag or link, making the email body a mess.</p>
<p>To avoid this, you have to use base64 encoding on the email body header:</p>
<p>&#8220;Content-Transfer-Encoding: base64\r\n&#8221;</p>
<p>The second thing you have to do is to encode your content string with base64 and chunk it into chunks before appending to the email.</p>
<p>chunk_split(base64_encode($content))</p>
<p>base64 encoding is something email clients can read and because the sting of HTML is encoded into this format you don&#8217;t get the spaces between every chunk of content when the client displays the content.</p>
<p>These two lines is the only thing you probably need to append when you ha long text or large emails with data longer than 998 chars. Today I encountered this problem again, and I knew about the solution so I knew what to google to find the right answer. But I did not find it right away, because there was not any really good, and short, explanation anywhere that said exactly what I needed to do.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/individualweb.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/individualweb.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/individualweb.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/individualweb.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/individualweb.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/individualweb.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/individualweb.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/individualweb.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/individualweb.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/individualweb.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/individualweb.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/individualweb.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/individualweb.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/individualweb.wordpress.com/154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=individualweb.wordpress.com&amp;blog=12023890&amp;post=154&amp;subd=individualweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://individualweb.wordpress.com/2011/03/17/send-large-emails-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9bbab75734efe135a56b332b7f9c00f6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">individualweb</media:title>
		</media:content>
	</item>
	</channel>
</rss>
