<?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>ZENVERSE &#187; Web Development</title>
	<atom:link href="http://zenverse.net/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://zenverse.net</link>
	<description>Design and Web Development</description>
	<lastBuildDate>Tue, 15 Jan 2013 15:12:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>[Javascript] Search Box to Show Default Text on Load and Cleared When Focused</title>
		<link>http://zenverse.net/javascript-search-box-show-default-text-on-load/</link>
		<comments>http://zenverse.net/javascript-search-box-show-default-text-on-load/#comments</comments>
		<pubDate>Mon, 09 Jul 2012 13:35:15 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[searchbox]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2630</guid>
		<description><![CDATA[Very often we want our search box to show a default text such as "Search..." when it is loaded. Then when users clicked on the search box, the word is cleared, allowing user to enter their search query. We will see how to do that in this short guide in both plain Javascript and jQuery. ]]></description>
				<content:encoded><![CDATA[<p>Very often we want our search box to show a default text such as &#8220;Search&#8230;&#8221; when it is loaded. Then when users clicked on the search box, the word is cleared, allowing user to enter their search query. We will see how to do that in this short guide in both plain Javascript and jQuery. </p>
<p>You can use the jQuery method if your website is already using jQuery library. If not, it is not recommended because there is no need to load a library just for this simple script.</p>
<h3>Demo Page</h3>
<p><a href="http://zenverse.net/wp-content/uploads/2012/07/js-search-box.html" title="Search Box to show default text on load and cleared when focused" target="_blank"><strong><em>Click here to go to the DEMO PAGE</em></strong></a></p>
<h3>Using Plain Javascript</h3>
<p>Below shows the codes to achieve the behavior in a simple search form using plain javascript.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2630code1'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p26301"><td class="code" id="p2630code1"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&nbsp;
&lt;body&gt;
&nbsp;
&lt;form method=&quot;get&quot; action=&quot;&quot;&gt;
	&lt;input type=&quot;text&quot; name=&quot;search&quot; id=&quot;search&quot; value=&quot;&quot; /&gt;
	&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Search&quot; /&gt;
&lt;/form&gt;
&nbsp;
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
	var defaultText = &quot;Search...&quot;;
	var searchBox = document.getElementById(&quot;search&quot;);
&nbsp;
	//default text after load
	searchBox.value = defaultText;
&nbsp;
	//on focus behaviour
	searchBox.onfocus = function() {
		if (this.value == defaultText) {//clear text field
			this.value = '';
		}
	}
&nbsp;
	//on blur behaviour
	searchBox.onblur = function() {
		if (this.value == &quot;&quot;) {//restore default text
			this.value = defaultText;
		}
	}
&nbsp;
//--&gt;
&lt;/script&gt;
&nbsp;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>It is pretty straightforward, we just need to set the default text, the onfocus &#038; onblur behaviors to the search form&#8217;s text &lt;input> element.<br />
But make sure you placed the javascript codes AFTER the search form or else you will get an error complaining that the element doesn&#8217;t exist.</p>
<h3>Using JQuery</h3>
<p>Below shows the codes for jQuery, where the jQuery library is loaded from Google API. You can also use your local copy of jquery.js if you want.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2630code2'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p26302"><td class="code" id="p2630code2"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
&nbsp;
&lt;script type=&quot;text/javascript&quot; src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
	&lt;!--
&nbsp;
		$(document).ready(function() {
			var defaultText = &quot;Search...&quot;;
			var searchBox = $('#search2');
&nbsp;
			//set default text on load
			searchBox.val(defaultText);
&nbsp;
			//on focus behaviour
			searchBox.focus(function(){
				if ($(this).val() == defaultText) {//clear text field
					$(this).val('');
				}
			});
&nbsp;
			//on blur behaviour
			searchBox.blur(function(){
				if ($(this).val() == &quot;&quot;) {//restore default text
					$(this).val(defaultText);
				}
			});
&nbsp;
&nbsp;
		});
&nbsp;
	//--&gt;
	&lt;/script&gt;
&lt;/head&gt;
&nbsp;
&lt;body&gt;	
	&lt;form method=&quot;get&quot; action=&quot;&quot;&gt;
		&lt;input type=&quot;text&quot; name=&quot;search2&quot; id=&quot;search2&quot; value=&quot;&quot; /&gt;
		&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Search&quot; /&gt;
	&lt;/form&gt;
&nbsp;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>Similar codes go for jQuery but with different syntax. Also, for jQuery, you can put the javascript anywhere (it does not matter before or after the form)</p>
<p>Hope this short guide helps. Please Share or Like it if it does :) </p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/javascript-search-box-show-default-text-on-load/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Code to Get Current Page&#8217;s URL</title>
		<link>http://zenverse.net/php-code-get-current-page-url/</link>
		<comments>http://zenverse.net/php-code-get-current-page-url/#comments</comments>
		<pubDate>Sun, 01 Jul 2012 14:43:05 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2626</guid>
		<description><![CDATA[It is quite often that we need to redirect users back to current URL. I wrote my own function for this purpose, but then I realized some weaknesses: it cannot capture HTTPS and the port number, which is very important for some websites.]]></description>
				<content:encoded><![CDATA[<p>It is quite often that we need to redirect users back to current URL. I wrote my own function for this purpose, but then I realized some weaknesses: it cannot capture HTTPS and the port number, which is very important for some websites. Luckily, I found this piece of code from <a target="_blank" href="http://dev.kanngard.net/Permalinks/ID_20050507183447.html">dev.kanngard.net</a> which does the magic:</p>
<h3>The PHP Code</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2626code3'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p26263"><td class="code" id="p2626code3"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> getCurrentURL<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;HTTPS&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">''</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;HTTPS&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;on&quot;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;s&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$protocol</span> <span style="color: #339933;">=</span> strleft<span style="color: #009900;">&#40;</span><a href="http://www.php.net/strtolower"><span style="color: #990000;">strtolower</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SERVER_PROTOCOL&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$s</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$port</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SERVER_PORT&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;80&quot;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;:&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SERVER_PORT&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$protocol</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;://&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SERVER_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #000088;">$port</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//usage</span>
<span style="color: #b1b100;">echo</span> getCurrentURL<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>It works perfectly in returning the following URLs</h3>
<ul>
<li>http://localhost/</li>
<li>http://localhost/a.html?b=1</li>
<li>http://localhost:8080/a.html</li>
<li>https://example.com/a/b/c.html?b=1</li>
</ul>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/php-code-get-current-page-url/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fixing Javascript Error: Property &#8216;submit&#8217; of object #&lt;HTMLFormElement&gt; is not a function</title>
		<link>http://zenverse.net/js-property-submit-of-object-htmlformelement-is-not-function/</link>
		<comments>http://zenverse.net/js-property-submit-of-object-htmlformelement-is-not-function/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 09:55:25 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2499</guid>
		<description><![CDATA[If you come across this error when you code your javascript, most probably you are trying to submit the form dynamically using javascript. Don't worry, the solution is easy.]]></description>
				<content:encoded><![CDATA[<blockquote><p>Property &#8216;submit&#8217; of object #<HTMLFormElement> is not a function</p></blockquote>
<p>If you come across this error in javascript, most probably you are trying to submit the form dynamically using javascript. Don&#8217;t worry, the solution is easy.</p>
<h3>The Solution</h3>
<p>Check your &lt;form> element. It MUST not have any HTML element with ID attribute of &#8220;submit&#8221;.<br />
If you have such element, rename the ID attribute to some other name.</p>
<h3>Explanation</h3>
<p>Let&#8217;s say if your form element has a button with ID &#8220;submit&#8221;. When you trigger yourform.submit(), your browser actually tries to run your button element as a function instead of running the form&#8217;s submit function. </p>
<p>Hope this helps. Please &#8220;Like&#8221; this post if it works for you :)</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/js-property-submit-of-object-htmlformelement-is-not-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Remove Facebook Cache of Your Page&#8217;s Metadata</title>
		<link>http://zenverse.net/remove-facebook-cache-of-your-page-matadata/</link>
		<comments>http://zenverse.net/remove-facebook-cache-of-your-page-matadata/#comments</comments>
		<pubDate>Sun, 04 Mar 2012 14:14:21 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[facebook]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2506</guid>
		<description><![CDATA[Whenever Facebook visited a page (most probably when someone shared your URL on Facebook), your page's metadata will be cached. I am not sure when the cache expires, but you can actually clear the cache easily by directing your browser to this address below]]></description>
				<content:encoded><![CDATA[<p>Whenever Facebook visited a page (most probably when someone shared your URL on Facebook), your page&#8217;s metadata will be cached. I am not sure when the cache expires, but you can actually clear the cache easily by directing your browser to this address below:</p>
<blockquote><p>http://developers.facebook.com/tools/debug/og/object?q=[YOUR_PAGE_URL]&#038;fbrefresh=any</p></blockquote>
<p>Of course, replace &#8220;[YOUR_PAGE_URL]&#8221; with your page URL and you are good to go.</p>
<p>I also created a quick page for you to <a href="http://tools.zenverse.net/clear-facebook-cache/" title="Clear Facebook Cache Metadata" target="_blank">clear facebook cache of any page</a> in my WebTools Site. You can bookmark this page to use it in future.</p>
<p>Hope this helps :)</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/remove-facebook-cache-of-your-page-matadata/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reducing Image File Size (Compression) using PHP GD</title>
		<link>http://zenverse.net/php-reducing-image-filesize-using-gd/</link>
		<comments>http://zenverse.net/php-reducing-image-filesize-using-gd/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 09:11:23 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2478</guid>
		<description><![CDATA[Most of the time, photos uploaded by users are not optimized for web. In other words, they might not be using the best file format for their photos, thus taking much more spaces in your server than it actually need. Using PHP, you can easily reduce the file size of those uploaded images during upload time.  But of course, when reducing the file size, we sacrifice the image quality. Therefore, if you are running image uploader website, this is not recommended.]]></description>
				<content:encoded><![CDATA[<p>Most of the time, photos uploaded by users are not optimized for web. In other words, they might not be using the best file format for their photos, thus taking much more spaces in your server than it actually need. Using PHP, you can easily reduce the file size of those uploaded images during upload time. But of course, when reducing the file size, we sacrifice the image quality. Therefore, if you are running image uploader website, this is not recommended.</p>
<h3>The simple function</h3>
<p>The best file format for photo is JPEG as it provides the best reduction in file size. The downside is losing details &#8211; your photo will be blurred depending on your quality setting. If your photo contains crisp texts, the text will most likely be blurred. Check out the code below.</p>
<p>This function below can load from PNG, JPEG or GIF file ($source_url) and save the compressed photo as JPEG in $destination_url.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2478code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24784"><td class="code" id="p2478code4"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> compress_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$destination_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$quality</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$info</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/getimagesize"><span style="color: #990000;">getimagesize</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mime'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'image/jpeg'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefromjpeg"><span style="color: #990000;">imagecreatefromjpeg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mime'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'image/gif'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefromgif"><span style="color: #990000;">imagecreatefromgif</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mime'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'image/png'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefrompng"><span style="color: #990000;">imagecreatefrompng</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//save file</span>
	<a href="http://www.php.net/imagejpeg"><span style="color: #990000;">imagejpeg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$destination_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$quality</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//return destination file</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$destination_url</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//usage</span>
<span style="color: #000088;">$compressed</span> <span style="color: #339933;">=</span> compress_image<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'source.png'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'destination.jpg'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><b>Explanation</b></p>
<ul>
<li>imagecreatefromjpeg() is where PHP loads your source image.</li>
<li>imagejpeg() is the part where PHP output the image. In our case, we specified the second parameter (destination_url) therefore PHP saved the image instead of outputting it.</li>
<li>You can control the quality of the image. In the example above, we used 90/100 to maintain the quality of the photo while reducing file size. You need to try out various setting to suit your need.</li>
<h3>A quick testing page</h3>
<p>I have written a small PHP page to test the image compression. It put your original and compressed photos side by side so that you can compare the quality and file size. Save it as compress.php, change the image URL and quality setting then run it in your server.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2478code5'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24785"><td class="code" id="p2478code5"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> compress_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$destination_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$quality</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$info</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/getimagesize"><span style="color: #990000;">getimagesize</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mime'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'image/jpeg'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefromjpeg"><span style="color: #990000;">imagecreatefromjpeg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mime'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'image/gif'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefromgif"><span style="color: #990000;">imagecreatefromgif</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mime'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'image/png'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefrompng"><span style="color: #990000;">imagecreatefrompng</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//save it</span>
	<a href="http://www.php.net/imagejpeg"><span style="color: #990000;">imagejpeg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$destination_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$quality</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//return destination file url</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$destination_url</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$source_photo</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'uploads/source.jpg'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dest_photo</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'uploads/testing.jpg'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$d</span> <span style="color: #339933;">=</span> compress_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_photo</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dest_photo</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'
&lt;div style=&quot;float:left;margin-right:10px&quot;&gt;
	&lt;img src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$source_photo</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; alt=&quot;&quot; /&gt;
	&lt;br /&gt;'</span><span style="color: #339933;">.</span><a href="http://www.php.net/filesize"><span style="color: #990000;">filesize</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_photo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' Bytes
&lt;/div&gt;
&nbsp;
&lt;div style=&quot;float:left;&quot;&gt;
	&lt;img src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$dest_photo</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; alt=&quot;&quot; /&gt;
	&lt;br /&gt;'</span><span style="color: #339933;">.</span><a href="http://www.php.net/filesize"><span style="color: #990000;">filesize</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dest_photo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' Bytes
&lt;/div&gt;
'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Hope this helps :)</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/php-reducing-image-filesize-using-gd/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Using oEmbed API to Embed Videos</title>
		<link>http://zenverse.net/php-oembed-embed-videos/</link>
		<comments>http://zenverse.net/php-oembed-embed-videos/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 08:53:09 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2445</guid>
		<description><![CDATA[oEmbed is a format for allowing an embedded representation of a URL on third party sites. Which means, if we have a video page's URL, we can easily get the video thumbnail photo, video title, HTML code to embed it in our website and more. But of course, the video site must have oEmbed support in order for us to do that.]]></description>
				<content:encoded><![CDATA[<p>oEmbed is a format for allowing an embedded representation of a URL on third party sites. Which means, if we have a video page&#8217;s URL, we can easily get the video thumbnail photo, video title, HTML code to embed it in our website and more. But of course, the video site must have oEmbed support in order for us to do that. Check out <a rel="nofollow" target="_blank" href="http://oembed.com">http://oembed.com</a> for full documentation.</p>
<h3>Let&#8217;s look at how YouTube oEmbed works</h3>
<p>1. First, send a request to YouTube&#8217;s Oembed API page with a video URL (must be urlencoded) as parameter and we also specified that we want it to be returned in json format.</p>
<blockquote><p><a rel="nofollow" target="_blank" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch%3Fv%3DbDOYN-6gdRE&#038;format=json">http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch%3Fv%3DbDOYN-6gdRE&#038;format=json</a>
</p></blockquote>
<p>2. You will then see a long json-encoded string which contains all information about the video.</p>
<p>3. Next thing you need to do is just simply json-decode the string using your programming language, then you are free to use the information. We will see how to do that in PHP.</p>
<h3>Using Oembed to Embed Youtube Videos in PHP</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2445code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24456"><td class="code" id="p2445code6"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$videourl</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.youtube.com/watch?v=gB4nwqNM190'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$json</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://www.youtube.com/oembed?url='</span><span style="color: #339933;">.</span><a href="http://www.php.net/urlencode"><span style="color: #990000;">urlencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$videourl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;format=json'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$decode</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/json_decode"><span style="color: #990000;">json_decode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$json</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$decode</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #000088;">$decode</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//error control here</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$thumb</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$decode</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'thumbnail_url'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$decode</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'html'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>It&#8217;s pretty straightforward and self-explanatory:</p>
<ul>
<li>First, we send a url request to YouTube&#8217;s obembed API page using file_get_contents() function.</li>
<li>Second, we decode the response using json_decode() function which convert json format to array.</li>
<li>Third, if there is no error in decoding, we then assign $thumb and $html and use it in our website or program.</li>
</ul>
<h3>Extra: If you want to limit the embedded video&#8217;s width or height</h3>
<p>You can specify the max height or max width by appending the maxwidth or maxheight parameters to the oembed URL. (Please note that this cannot resize a smaller video to bigger size)</p>
<p>For example, from our example above, to specify max width of 300 pixels:</p>
<blockquote><p><a rel="nofollow" target="_blank" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch%3Fv%3DbDOYN-6gdRE&#038;format=json&#038;maxwidth=300">http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch%3Fv%3DbDOYN-6gdRE&#038;format=json&#038;maxwidth=300</a></p></blockquote>
<p>You should notice the video embedding code (iframe) is now limited to width of 300 pixels.</p>
<h3>How do I embed videos from other video sites like Vimeo?</h3>
<p>Most of the popular video sites has oEmbed support just like YouTube. For example, by <a target="_blank" href="http://www.google.com/search?q=vimeo+oembed">googling &#8220;vimeo oembed&#8221;</a> we found vimeo oembed documentation.</p>
<p>In vimeo, this is the URL we should send our request to:</p>
<blockquote><p><a rel="nofollow" href="http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/7100569" target="_blank">http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/7100569</a></p></blockquote>
<p>More details about oEmbed API page for other video sites will be covered in our next blog post (coming soon).</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/php-oembed-embed-videos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP MySQL &#8211; Get Next Auto Increment Value of a Table</title>
		<link>http://zenverse.net/php-mysql-next-auto-increment-value/</link>
		<comments>http://zenverse.net/php-mysql-next-auto-increment-value/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 06:05:14 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2404</guid>
		<description><![CDATA[We do not often need this but sometimes when we need to retrieve the next auto increment value of a table (without incrementing the auto increment value of course), this solution below will help.]]></description>
				<content:encoded><![CDATA[<p>We do not often need this but sometimes when we need to retrieve the next auto increment value of a table (without incrementing the auto increment value of course), this solution below will help.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2404code7'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24047"><td class="code" id="p2404code7"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SHOW TABLE STATUS WHERE name='your_table_name_here'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/mysql_num_rows"><span style="color: #990000;">mysql_num_rows</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #990000;">mysql_fetch_assoc</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Auto_increment'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//error</span>
	<span style="color: #666666; font-style: italic;">//error control here</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Just replace &#8220;your_table_name_here&#8221; with your mySQL table name.</p>
<h3>As a Function</h3>
<p>Furthermore, making it a PHP function would make the solution looks clean.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2404code8'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24048"><td class="code" id="p2404code8"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> get_next_value<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tablename</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SHOW TABLE STATUS WHERE name='&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/mysql_real_escape_string"><span style="color: #990000;">mysql_real_escape_string</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tablename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/mysql_num_rows"><span style="color: #990000;">mysql_num_rows</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #990000;">mysql_fetch_assoc</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Auto_increment'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//error</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//usage</span>
<span style="color: #000088;">$nextval</span> <span style="color: #339933;">=</span> get_next_value<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'your_table_name_here'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/php-mysql-next-auto-increment-value/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Smart Date Function &#8211; Display Time Elapsed (Difference) Based on a Given Timestamp</title>
		<link>http://zenverse.net/php-smart-date-function/</link>
		<comments>http://zenverse.net/php-smart-date-function/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 04:43:29 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2371</guid>
		<description><![CDATA[As a web developer, we often need to display dates in our website. As a web user myself, I don't like to read full dates like "26 November 2011 11:30PM" because it takes me a little while to interpret the date. I prefer reading smart dates like "1 hour ago" or "6 months ago". Therefore, here I wrote a quick and simple function in PHP that display the time difference/elapsed based on a given timestamp value.]]></description>
				<content:encoded><![CDATA[<p>As a web developer, we often need to display dates in our website. As a web user myself, I don&#8217;t like to read full dates like &#8220;26 November 2011 11:30PM&#8221; because it takes me a little while to interpret the date. I prefer reading smart dates like &#8220;1 hour ago&#8221; or &#8220;6 months ago&#8221;. Therefore, here I wrote a quick and simple function in PHP that display the time difference/elapsed based on a given timestamp value.</p>
<h3>PHP Smart Date Function</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2371code9'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23719"><td class="code" id="p2371code9"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
Simple PHP Smart Date Function
by Zen (http://zenverse.net)
*/</span>
<span style="color: #000000; font-weight: bold;">function</span> smartdate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$diff</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/time"><span style="color: #990000;">time</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$timestamp</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'Now'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' second(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' minute(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' hour(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' day(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">30</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' month(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">30</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' year(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> grammar_date<span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sentence</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$val</span><span style="color: #339933;">.</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'(s)'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'s'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sentence</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$val</span><span style="color: #339933;">.</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'(s)'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sentence</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Basically I defined 2 functions above:<br />
<strong>smartdate</strong> &#8211; calculates the difference between given timestamp and current time, then returns the correct sentence<br />
<strong>grammar_date</strong> &#8211; modifies the returned sentence to plural form or singular form</p>
<h3>Usage</h3>
<p>The usage is simple and straightforward.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2371code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p237110"><td class="code" id="p2371code10"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//example 1</span>
<span style="color: #b1b100;">echo</span> smartdate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$yourtimestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//example 2</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Posted on '</span><span style="color: #339933;">.</span>smartdate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$yourtimestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>By default, this function returns the floor() value, i.e: instead of returning &#8220;1.7 years ago&#8221;, it returns &#8220;1 year ago&#8221;. Anyway, the function can be easily modified to suit your specific needs.</p>
<h3>Give users the choice to view the full date</h3>
<p>1 disadvantage of smart date is of course, it reduces the level of detail and granularity of the date information. For example, dates of 13 months ago or 19 months ago will both be displayed as &#8220;1 year ago&#8221;.</p>
<p>The most common way to let user view the full date is to add a &#8220;title&#8221; attribute with full date as the attribute value. Now, when user mouseover your smart date, they can see the full date popping up as tooltip. Facebook uses this approach.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2371code11'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p237111"><td class="code" id="p2371code11"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//from example 2 above</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Posted on &lt;span title=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$originalfulldate</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> smartdate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$yourtimestamp</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/php-smart-date-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cannot Access Localhost After Editing etc/hosts and Flushing DNS Cache</title>
		<link>http://zenverse.net/cannot-access-localhost-after-editing-etchosts-flush-cache/</link>
		<comments>http://zenverse.net/cannot-access-localhost-after-editing-etchosts-flush-cache/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 16:23:42 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Apple/Mac]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2354</guid>
		<description><![CDATA[I was developing a new website that uses Facebook Login as the membership system. I came across this situation where I needed to create a "fake" domain by editing the etc/hosts file. Somehow, after editing the etc/hosts file (following an online guide), I cannot seems to browse http://localhost in my browser anymore. However, I can still browse my local apache server using http://127.0.0.1]]></description>
				<content:encoded><![CDATA[<p>I was developing a new website that uses Facebook Login as the membership system. I came across this situation where I needed to create a &#8220;fake&#8221; domain by editing the etc/hosts file. Somehow, after editing the etc/hosts file (following an online guide), I cannot seems to browse http://localhost in my browser anymore. However, I can still browse my local apache server using http://127.0.0.1</p>
<blockquote><p><strong>NOTE:</strong><br />
This is not XAMPP / apache issue<br />
This is not browser-specific issue
</p></blockquote>
<p>In fact, this is a simple problem with simple solution. However, this problem occurs when I am getting frustrated with the Facebook integration problem (after 12 hours of debugging). Therefore, I missed some simple but important steps to solve this problem. Here I list them down below:</p>
<h3>1. Ping Localhost</h3>
<p>For Mac OS users, open up your Terminal. For windows users, open up your command prompt.</p>
<ul>
<li>Type the &#8220;ping localhost&#8221; and press enter.</li>
<li>You should get error messages like &#8220;unknown host&#8221; since you are having this problem.</li>
</ul>
<ul>
<li>Next, type &#8220;ping 127.0.0.1&#8243; and press enter.</li>
<li>If you saw something like this, the ping is successful:

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2354code12'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p235412"><td class="code" id="p2354code12"><pre class="cmd" style="font-family:monospace;">PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.118 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.171 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.167 ms</pre></td></tr></table></div>

</li>
<li>If you get &#8220;unknown host error&#8221;, please check whether you have started your local server service.</li>
</ul>
<h3>2. Clear your browser cache</h3>
<p>Modern browsers cache a lot of stuff, including DNS cache. They may have cached the erroneous DNS setting in etc/hosts, so you might want to clear your browsers cache and try loading localhost again. Clearing cache alone would already be sufficient, you can skip clearing cookies, saved session, etc.</p>
<p>If it still doesn&#8217;t work, try #3 below.</p>
<h3>3. Did you just flushed the DNS cache?</h3>
<p>I ran this command in terminal (Mac) to flush my cache before I get into this mess: &#8220;dscacheutil -flushcache&#8221;<br />
For some reason, after I flushed the cache, the DNS setting is not being rebuilt &#8211; I cannot ping localhost but I can ping 127.0.0.1</p>
<p>After restarting my laptop (to rebuild the DNS settings &#038; cache) and clearing all browser cache once again, I finally get my localhost displayed again.</p>
<p>Now I hope this helps some of you.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/cannot-access-localhost-after-editing-etchosts-flush-cache/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Legacy Facebook &#8220;Share&#8221; Button Codes (Bubble Count, Box Count and More)</title>
		<link>http://zenverse.net/legacy-facebook-share-button-code/</link>
		<comments>http://zenverse.net/legacy-facebook-share-button-code/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 16:12:32 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[facebook]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2329</guid>
		<description><![CDATA[Few months ago, Facebook removed the page that allow us to generate codes for their official "Share" button. They replaced it with <a href="https://developers.facebook.com/docs/reference/plugins/like" target="_blank">"Like" button</a> instead. While "Like" button is fast and easy but we cannot add our comment along with the "Like" action. Therefore, in some cases, we still need the old Share button. Fortunately, the sharer.php still exists, so we can add the Share button using Facebook's official script.]]></description>
				<content:encoded><![CDATA[<p>Few months ago, Facebook removed the page that allow us to generate codes for their official &#8220;Share&#8221; button. They replaced it with <a href="https://developers.facebook.com/docs/reference/plugins/like" target="_blank">&#8220;Like&#8221; button</a> instead. While &#8220;Like&#8221; button is fast and easy but we cannot add our comment along with the &#8220;Like&#8221; action. Therefore, in some cases, we still need the old Share button. Fortunately, the sharer.php still exists, so we can add the Share button using Facebook&#8217;s official script.</p>
<p>Here are the complete codes for all sizes of Facebook share button for those who are interested:</p>
<h3>Box Count</h3>
<p><a name="fb_share" type="box_count" href="http://www.facebook.com/sharer.php">Share</a> &nbsp;*count will only visible when there is at least 1 share</p>
<div class="clear"></div>
<p>Codes:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2329code13'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p232913"><td class="code" id="p2329code13"><pre class="html" style="font-family:monospace;">&lt;a name=&quot;fb_share&quot; type=&quot;box_count&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Button Count</h3>
<p><a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a> *count will only visible when there is at least 1 share</p>
<p>Codes:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2329code14'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p232914"><td class="code" id="p2329code14"><pre class="html" style="font-family:monospace;">&lt;a name=&quot;fb_share&quot; type=&quot;button_count&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Button only</h3>
<p><a name="fb_share" type="button" href="http://www.facebook.com/sharer.php">Share</a></p>
<p>Codes:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2329code15'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p232915"><td class="code" id="p2329code15"><pre class="html" style="font-family:monospace;">&lt;a name=&quot;fb_share&quot; type=&quot;button&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Small Icon only</h3>
<p><a name="fb_share" type="icon" href="http://www.facebook.com/sharer.php">Share</a></p>
<p>Codes:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2329code16'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p232916"><td class="code" id="p2329code16"><pre class="html" style="font-family:monospace;">&lt;a name=&quot;fb_share&quot; type=&quot;icon&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Custom URL?</h3>
<p>All codes above &#8220;shares&#8221; the current page. If you want to share another page or a specific page, you need to add a &#8220;share_url&#8221; attribute to the &lt;a> tag. You need this too when you have multiple share buttons in a single page.</p>
<p>Example below shares our main website http://zenverse.net instead of this page.</p>
<p><a name="fb_share" type="button_count" share_url="http://zenverse.net" href="http://www.facebook.com/sharer.php">Share</a></p>
<p>Here&#8217;s how:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2329code17'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p232917"><td class="code" id="p2329code17"><pre class="html" style="font-family:monospace;">&lt;a name=&quot;fb_share&quot; type=&quot;button_count&quot; share_url=&quot;http://zenverse.net&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Multiple Share Buttons</h3>
<p>If you have multiple share buttons in a single page, you just need to include the &lt;script> element <b>once</b>.</p>
<p>Hope this helps.</p>
<p><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/legacy-facebook-share-button-code/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
