<?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>TutorBoy &#187; PHP</title>
	<atom:link href="http://articles.tutorboy.com/topics/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://articles.tutorboy.com</link>
	<description>Log on to Techknowledgey</description>
	<lastBuildDate>Wed, 18 Jan 2012 09:06:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Zend Developer Cloud</title>
		<link>http://articles.tutorboy.com/2011/10/19/zend-developer-cloud/</link>
		<comments>http://articles.tutorboy.com/2011/10/19/zend-developer-cloud/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 07:18:25 +0000</pubDate>
		<dc:creator>Midhun Devasia</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://articles.tutorboy.com/?p=2977</guid>
		<description><![CDATA[
Zend Developer Cloud, as its name suggests, a cloud-based environment designed to help you code more quickly and more efficiently. ...]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-2978 alignright" title="phpcloud" src="http://articles.tutorboy.com/content/uploads/2011/10/phpcloud.jpg" alt="" width="350" height="203" /></p>
<p>Zend Developer Cloud, as its name suggests, a cloud-based environment designed to help you code more quickly and more efficiently. It includes a robust PHP stack, advanced debugging capabilities, collaboration tools and much more. Zend Developer Cloud is only a few clicks away and does not require any<span id="more-2977"></span> installation. To make it even better, it’s absolutely free!</p>
<p>With Zend Developer Cloud, you get instant access to a complete PHP environment from Zend, the PHP Company. It includes the PHP runtime, a large set of PHP extensions, Zend Framework and more, so you no longer need to spend time on building the stack yourself.</p>
<p>Use a unique code tracing capability to quickly pinpoint root cause of issues without having to recreate them. Just like a flight recorder on a plane, your code is recorded, so when errors occur, you can easily step back in time and find the root cause.</p>
<p>See How it works<br />
<iframe src="http://www.youtube.com/embed/veDkBkl8K5M" frameborder="0" width="580" height="325"></iframe></p>
<p>[for more: <a href="http://www.phpcloud.com/">http://www.phpcloud.com</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://articles.tutorboy.com/2011/10/19/zend-developer-cloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: extract and compact functions</title>
		<link>http://articles.tutorboy.com/2011/04/30/php-extract-and-compact-functions/</link>
		<comments>http://articles.tutorboy.com/2011/04/30/php-extract-and-compact-functions/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 18:19:40 +0000</pubDate>
		<dc:creator>Midhun Devasia</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Array Extract]]></category>
		<category><![CDATA[compact]]></category>
		<category><![CDATA[extract]]></category>
		<category><![CDATA[PHP Functions]]></category>

		<guid isPermaLink="false">http://articles.tutorboy.com/?p=2803</guid>
		<description><![CDATA[I was looking for a shortcut to easy up my variable declaration in PHP coding, the extract and compact functions ...]]></description>
			<content:encoded><![CDATA[<p>I was looking for a shortcut to easy up my variable declaration in PHP coding, the extract and compact functions are pretty good for that. But don&#8217;t think this will help you in all the cases, I strongly recommend that don&#8217;t use this functions directly unless  your variable/values are sanitized. Because when you are using this directly in to a MySQL query statement with values from the input request variable will increase the security risks.<span id="more-2803"></span></p>
<p>Okey, lets assume that your data are sanitized well, then look into the following.</p>
<p><strong>extract</strong> — Extract function import the variable from an array to the current symbol table.<br />
ie. if you have an associative array like $a = array(&#8216;user_name&#8217; =&gt; &#8216;midhun devasia&#8217;, &#8216;email_id&#8217; =&gt; &#8216;mymail@mydomain.com&#8217;), and wanted to use this as variable name, we usually try this method $user_name =  $a['user_name']; instead of that we will get all variable into our current symbol table by using extract function.</p>
<pre class="brush:php">$a = array('user_name' =&gt; 'midhun devasia', 'email_id' =&gt; 'myemail@mydoamin.com');

extract($a);
echo "Hello ", $user_name, "Your email id is ", $email_id;</pre>
<p>The first param is the array, and second param is optional , there you can pass to overwrite the variable values, add prefix etc options. see the PHP Manuel for more info.</p>
<p><strong>compact</strong> — Create array containing variables and their values.<br />
If you want to pass some variable values into an array as its key and values.</p>
<pre class="brush:php">$user_name = "Midhun Devasia";
$email_id = "myemail@domain.com";

$result = compact("user_name", "email_id");

/*
 echo $result['user_name'] is Midhun Devasia
 */</pre>
]]></content:encoded>
			<wfw:commentRss>http://articles.tutorboy.com/2011/04/30/php-extract-and-compact-functions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP: parse_ini_file and parse_ini_string</title>
		<link>http://articles.tutorboy.com/2011/03/15/parse_ini_file-and-parse_ini_string/</link>
		<comments>http://articles.tutorboy.com/2011/03/15/parse_ini_file-and-parse_ini_string/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 07:13:48 +0000</pubDate>
		<dc:creator>Midhun Devasia</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[parse_ini_file]]></category>
		<category><![CDATA[parse_ini_string]]></category>
		<category><![CDATA[PHP Functions]]></category>

		<guid isPermaLink="false">http://articles.tutorboy.com/?p=2699</guid>
		<description><![CDATA[If you are thinking about to play with configuration files for your site&#8217;s settings, then in php you can easily ...]]></description>
			<content:encoded><![CDATA[<p>If you are thinking about to play with configuration files for your site&#8217;s settings, then in php you can easily parse the INI files using <strong>parse_ini_file</strong> and <strong>parse_ini_string</strong> functions.</p>
<p><a href="http://articles.tutorboy.com/content/uploads/2011/03/inifile.Sample.png"><img class="size-full wp-image-2700 aligncenter" title="INI file Sample" src="http://articles.tutorboy.com/content/uploads/2011/03/inifile.Sample.png" alt="" width="584" height="216" /></a><span id="more-2699"></span>The function <strong>parse_ini_file()</strong> parse a configuration file and <strong>parse_ini_string()</strong> will parse a configuration string, like if your config data came from database or other string format.</p>
<p><em><strong>parse_ini_file()</strong></em> function return an associative array of configuration data from a given file.</p>
<p>Params: <em><tt></tt></em><br />
<em><tt>filename : </tt></em>The filename of the ini file being parsed.<br />
<tt>process_sections: </tt>By setting the process_sections parameter to TRUE, you get a multidimensional array, with the section names and settings included. The default for process_sections is FALSE</p>
<h2>Sample Config File</h2>
<pre class="brush:css">; This is a sample configuration file
; Comments start with ';', as in php.ini
[first_section]
one = 1
five = 5
animal = BIRD

[second_section]
path = "/usr/local/bin"
URL = "http://www.example.com/~username"

[third_section]
phpversion[] = "5.0"
phpversion[] = "5.1"
phpversion[] = "5.2"
phpversion[] = "5.3"
</pre>
<h2>PHP Code</h2>
<pre class="brush:php">&lt;?php
	$settings = parse_ini_file('settings.ini');
	print_r($settings);
?&gt;</pre>
<h2>Out Put 1</h2>
<pre class="brush:css">Array
(
    [one] =&gt; 1
    [five] =&gt; 5
    [animal] =&gt; BIRD
    [path] =&gt; /usr/local/bin
    [URL] =&gt; http://www.example.com/~username
    [phpversion] =&gt; Array
        (
            [0] =&gt; 5.0
            [1] =&gt; 5.1
            [2] =&gt; 5.2
            [3] =&gt; 5.3
        )

)</pre>
<p>If the option value of process_sections is set as TRUE, the out put is as follows</p>
<h2>PHP Code 2</h2>
<pre class="brush:php">&lt;?php
	$settings = parse_ini_file('settings.ini', true);
	print_r($settings);
?&gt;</pre>
<h2>Out Put 2</h2>
<pre class="brush:css">Array
(
    [first_section] =&gt; Array
        (
            [one] =&gt; 1
            [five] =&gt; 5
            [animal] =&gt; BIRD
        )

    [second_section] =&gt; Array
        (
            [path] =&gt; /usr/local/bin
            [URL] =&gt; http://www.example.com/~username
        )

    [third_section] =&gt; Array
        (
            [phpversion] =&gt; Array
                (
                    [0] =&gt; 5.0
                    [1] =&gt; 5.1
                    [2] =&gt; 5.2
                    [3] =&gt; 5.3
                )

        )

)</pre>
<p>Everything is same as for parse_ini_string().<br />
Reference: <a href="http://www.php.net/manual/en/function.parse-ini-file.php">http://www.php.net/manual/en/function.parse-ini-file.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://articles.tutorboy.com/2011/03/15/parse_ini_file-and-parse_ini_string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework on shared hosting</title>
		<link>http://articles.tutorboy.com/2010/12/13/zend-framework-on-shared-hosting/</link>
		<comments>http://articles.tutorboy.com/2010/12/13/zend-framework-on-shared-hosting/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 06:17:31 +0000</pubDate>
		<dc:creator>Midhun Devasia</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://articles.tutorboy.com/?p=2581</guid>
		<description><![CDATA[Here is some tips and tricks to use Zend Framework on shared hosting. Click Here
]]></description>
			<content:encoded><![CDATA[<p>Here is some tips and tricks to use Zend Framework on shared hosting. <a title="Zend Framework on shared hosting" href="http://stackoverflow.com/questions/1115547/zend-framework-on-shared-hosting" target="_self"><span id="more-2581"></span>Click Here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://articles.tutorboy.com/2010/12/13/zend-framework-on-shared-hosting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XPath in JavaScript, PHP, ActionScript and jQuery</title>
		<link>http://articles.tutorboy.com/2010/09/27/xpath-in-javascript-php-actionscript-and-jquery/</link>
		<comments>http://articles.tutorboy.com/2010/09/27/xpath-in-javascript-php-actionscript-and-jquery/#comments</comments>
		<pubDate>Mon, 27 Sep 2010 06:30:15 +0000</pubDate>
		<dc:creator>Midhun Devasia</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Action Script 2.0]]></category>
		<category><![CDATA[Action Script 3.0]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Flash Component]]></category>
		<category><![CDATA[Flash CS3]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery from scratch]]></category>
		<category><![CDATA[Js]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://articles.tutorboy.com/?p=2497</guid>
		<description><![CDATA[XPath, the XML Path Language, is a query language for selecting nodes from an XML document or we can say ...]]></description>
			<content:encoded><![CDATA[<p><strong>XPath</strong>, the <strong>XML Path Language</strong>, is a query language for selecting nodes from an XML document or we can say XPath is a language for addressing parts of an XML document, designed to be used by both XSLT and XPointer. It also provides basic facilities for manipulation of strings, numbers and Boolean. Most of the languages were support this feature, if you didn&#8217;t find in respected language you will get from 3rd party libs. Here are some quick reference links to XPath &amp; XPath Libs.<span id="more-2497"></span></p>
<h1>Reference Links</h1>
<p>1. <a title="XPath Syntax" href="http://www.w3schools.com/XPath/xpath_syntax.asp" target="_blank">XPath Syntax</a></p>
<p>2. <a title="XML Path Language (XPath)" href="http://www.w3.org/TR/xpath/" target="_blank">XML Path Language (XPath)</a></p>
<p>3. <a title="XPath Examples .NET Framework 4" href="http://msdn.microsoft.com/en-us/library/ms256086.aspx" target="_blank">XPath Examples .NET Framework 4</a></p>
<p>4. <a title="Introduction to using XPath in JavaScript" href="https://developer.mozilla.org/en/Introduction_to_using_XPath_in_JavaScript" target="_blank">Introduction to using XPath in JavaScript</a></p>
<p>5. <a title="An XPath implementation for ActionScript 3.0. " href="http://code.google.com/p/xpath-as3/" target="_blank">An XPath implementation for ActionScript 3.0. </a></p>
<p>6. <a title="PHP XPath Tutorial " href="http://ditio.net/2008/12/01/php-xpath-tutorial-advanced-xml-part-1/" target="_blank">PHP XPath Tutorial </a></p>
<p>7. <a title="jQuery  XPath Selectors" href="http://docs.jquery.com/DOM/Traversing/Selectors" target="_blank">jQuery  XPath Selectors</a></p>
]]></content:encoded>
			<wfw:commentRss>http://articles.tutorboy.com/2010/09/27/xpath-in-javascript-php-actionscript-and-jquery/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Commonly Used Regular expressions</title>
		<link>http://articles.tutorboy.com/2010/07/27/commonly-used-regular-expressions/</link>
		<comments>http://articles.tutorboy.com/2010/07/27/commonly-used-regular-expressions/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 07:39:28 +0000</pubDate>
		<dc:creator>Midhun Devasia</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Regular Expression]]></category>

		<guid isPermaLink="false">http://articles.tutorboy.com/?p=1993</guid>
		<description><![CDATA[Here are some commonly used regular expressions. Most of them are applicable for PHP, JavaScript, Perl, Python and Java.
HTTP URL
/*
Matches: ...]]></description>
			<content:encoded><![CDATA[<p>Here are some commonly used regular expressions. Most of them are applicable for PHP, JavaScript, Perl, Python and Java.</p>
<h2>HTTP URL</h2>
<pre class="brush:php">/*
Matches: https://tutorboy.com, http://tutorboy.com:8080/profile.html
Nonmatches: ftp://tutorboy.com, ftp://tutorboy.com/
*/
Expression : /(https?):\/\/([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})(:\d{1,4})?([-\w\/#~:.?+=&amp;%@~]*)/
</pre>
<h2><span id="more-1993"></span>Email</h2>
<pre class="brush:php">/*
Matches: mail@mytutorboy.com, email@my-mail.com, info@mymail.mysite.net
Nonmatches: .@example.com, mittu@i-.com, ilov@example.a
*/
Expression : /^[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z_+])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9}$/
</pre>
<h2>Valid HTML Hex code</h2>
<pre class="brush:php">/*
Matches: #fff, #1a1, #996633
Nonmatches: #ff, FFFFFF
*/
Expression : /^#([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?$/
</pre>
<h2>Match date: MM/DD/YYYY HH:MM:SS</h2>
<pre class="brush:php">/*
Matches: 04/30/1978 20:45:38
Nonmatches: 4/30/1978 20:45:38, 4/30/78
*/
Expression : /^\d\d\/\d\d\/\d\d\d\d \d\d:\d\d:\d\d$/
</pre>
<h2>U.S. zip code</h2>
<pre>/*
Matches: 94941-3232, 10024
Nonmatches: 949413232
*/
Expression : /^\d{5}(-\d{4})?$/
</pre>
<h2>U.S. currency</h2>
<pre class="brush:php">/*
Matches: $20, $15,000.01
Nonmatches: $1.001, $.99
*/
Expression : /^\$\(d{1,3}(\,\d{3})*|\d+)(\.\d{2})?$/
</pre>
<h2>Dotted Quad IP address</h2>
<pre class="brush:php">/*
Matches: 127.0.0.1, 224.22.5.110
Nonmatches: 127.1
*/
Expression : /^(\d|[01]?\d\d|2[0-4]\d|25[0-5])\.(\d|[01]?\d\d|2[0-4]\d|25[0-5])\.(\d|[01]?\d\d|2[0-4]\d|25[0-5])\.(\d|[01]?\d\d|2[0-4]\d|25[0-5])$/
</pre>
<h2>MAC address</h2>
<pre class="brush:php">/*
Matches: 01:23:45:67:89:ab
Nonmatches: 01:23:45, 0123456789ab
*/
Expression : /^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$/
</pre>
<h2>Type/format  specifiers</h2>
<pre class="brush:php">/*
Matches: my number %d, Hello %s!!, %f, %’-20s
Nonmatches: my number %t, hello %p
*/
Expression : #(%[+-]?(([ 0]?)|('.)))-?(d*)(.d*)?[%bcdeufFosxX]#
</pre>
]]></content:encoded>
			<wfw:commentRss>http://articles.tutorboy.com/2010/07/27/commonly-used-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compress and Decompress Using Zend Library (Zip, Rar, Bz2, Gz, Lzf, Tar)</title>
		<link>http://articles.tutorboy.com/2010/05/15/compress-and-decompress-using-zend-library/</link>
		<comments>http://articles.tutorboy.com/2010/05/15/compress-and-decompress-using-zend-library/#comments</comments>
		<pubDate>Sat, 15 May 2010 05:30:49 +0000</pubDate>
		<dc:creator>Midhun Devasia</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[BZ2]]></category>
		<category><![CDATA[Gz]]></category>
		<category><![CDATA[Lzf]]></category>
		<category><![CDATA[RAR]]></category>
		<category><![CDATA[TAR]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[ZIP]]></category>

		<guid isPermaLink="false">http://tutorboy.com/articles/?p=1611</guid>
		<description><![CDATA[Zend Framework 1.10 allows you to perform files/folder compression and decompression, all types of compression methods are available. These features ...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;">Zend Framework 1.10 allows you to perform files/folder compression and decompression, all types of compression methods are available. These features are available in standard set of filters from Zend_Filter. Its really easy to create an Archive with the php_zip extension. The PHP 5.2.13 support all the extension for the compression, but older version will support the zip extension only. Make sure that the extension is available on your php, you can seen this from phpinfo(); function. <a href="http://articles.tutorboy.com/content/uploads/2010/05/phpinfo_zip.jpg"><img class="aligncenter size-full  wp-image-1626" style="border: 0pt none;" title="phpinfo_zip" src="http://articles.tutorboy.com/content/uploads/2010/05/phpinfo_zip.jpg" alt="phpinfo_zip" /></a><span id="more-1611"></span></p>
<p>PHP Code for Compress and Decompress files/folders. The code is based on Zend Framework 1.10.</p>
<h1>Compress</h1>
<pre class="brush:php">&lt;?php
include_once('Zend/Filter/Compress.php');
include_once('Zend/Filter/Decompress.php');
include_once('Zend/Filter/Compress/Zip.php');

$filter = new Zend_Filter_Compress(array(
'adapter' =&gt; 'Zip',
'options' =&gt; array(
'archive' =&gt; 'compressed.zip'
),
));

// For file
$source = '/opt/folder/image.jpg';
// For Folder
//$source = '/opt/folder/';

$compressed = $filter-&gt;filter($source);
// Returns true on success and creates the archive file
</pre>
<h1>Decompress</h1>
<pre class="brush:php">$target_directory= '/opt/folder';

$filter = new Zend_Filter_Decompress(array(
'adapter' =&gt; 'Zip',
'options' =&gt; array(
'target' =&gt; $target_directory,
)
));

$compressed = $filter-&gt;filter('compressed.zip');
// Returns true on success and decompresses the archive file
// into the given target directory
</pre>
<p>If you want to use the Bz2 then include <strong><em>include_once(&#8216;Zend/Filter/Compress/Bz2.php&#8217;);</em></strong> and change the &#8220;<strong><em>Zip</em></strong>&#8221; as &#8220;<strong><em>Bz2</em></strong>&#8220;. and so on for the kind of archives like <em><strong>Tar</strong></em>, <em><strong>Rar</strong></em>, <em><strong>Gz</strong></em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://articles.tutorboy.com/2010/05/15/compress-and-decompress-using-zend-library/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Common methods for indicating important comments</title>
		<link>http://articles.tutorboy.com/2010/04/24/common-methods-for-indicating-important-comments/</link>
		<comments>http://articles.tutorboy.com/2010/04/24/common-methods-for-indicating-important-comments/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 13:27:49 +0000</pubDate>
		<dc:creator>Midhun Devasia</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Action Script 2.0]]></category>
		<category><![CDATA[Action Script 3.0]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tutorboy.com/articles/?p=1533</guid>
		<description><![CDATA[Some common methods for indicating important comments are TODO, BUG, KLUDGE and TRICKY. You can try this in any language, ...]]></description>
			<content:encoded><![CDATA[<p>Some common methods for indicating important comments are TODO, BUG, KLUDGE and TRICKY. You can try this in any language, I&#8217;m using this in Action Script, PHP, Flex and Javascript and CSS also <img src='http://articles.tutorboy.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  .</p>
<p>1 . <strong>// :TODO: </strong> <em>Description</em><br />
Indicates that there is more to do here.<span id="more-1533"></span><br />
2. <strong>// :BUG: [bugid] </strong><em>Description</em><br />
Shows a known issue here. The comment should also explain the issue and optionally give a bug ID if applicable.<br />
3. <strong>// :KLUDGE:</strong> <em>Description</em><br />
Indicates that the following code is not elegant or does not conform to best practices. This comment alerts others to provide suggestions about how to code it differently next time.<br />
4. <strong>// :TRICKY:</strong> <em>Description</em><br />
Notifies developers that the subsequent code has a lot of interactions. Also advises developers that they should think twice before trying to modify it.</p>
]]></content:encoded>
			<wfw:commentRss>http://articles.tutorboy.com/2010/04/24/common-methods-for-indicating-important-comments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Crushing With Smush.it™</title>
		<link>http://articles.tutorboy.com/2010/04/01/image-crushing-with-smush-it/</link>
		<comments>http://articles.tutorboy.com/2010/04/01/image-crushing-with-smush-it/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 18:24:30 +0000</pubDate>
		<dc:creator>Midhun Devasia</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://tutorboy.com/articles/?p=1482</guid>
		<description><![CDATA[We have found many good tools for reducing image size. Often times these tools are specific to particular image formats ...]]></description>
			<content:encoded><![CDATA[<p>We have found many good tools for reducing image size. Often <a href="http://articles.tutorboy.com/content/uploads/2010/04/image_crush.jpg"><img class="alignright size-full wp-image-1483" style="margin-left: 10px; margin-right: 10px;" title="image_crush" src="http://articles.tutorboy.com/content/uploads/2010/04/image_crush.jpg" alt="" /></a>times these tools are specific to particular image formats and work much better in certain circumstances than others. To &#8220;smush&#8221; really means to try many different image reduction algorithms and figure out which one gives the best result. These are the tools which we frequently used on crushing, ie <a href="http://www.imagemagick.org/">Imagemagick</a> , <a href="http://pmt.sourceforge.net/pngcrush/">pngcrush</a>, <a href="http://jpegclub.org/losslessapps.html">jpegtran</a>, <a href="http://www.lcdf.org/gifsicle/">gifsicle</a> and finally Smush.it™ online application. <span id="more-1482"></span>Smush.it uses optimization techniques specific to image format to remove unnecessary bytes from image files. It is a &#8220;lossless&#8221; tool, which means it optimizes the images without changing their look or visual quality. Smush.it is included with YSlow and is no longer available as a separate download. <a href="https://addons.mozilla.org/en-US/firefox/addon/5369">Download YSlow</a> now to get Smush.it and start saving bytes on image files.</p>
<p><em>Smush.it</em> can process JPG, GIF, and PNG images that are up to one megabyte in size. Converting GIF files to PNG files often produces substantial performance improvements. <a href="http://www.smushit.com/ysmush.it/" target="_blank">Here </a>you can Smush your image files online.</p>
]]></content:encoded>
			<wfw:commentRss>http://articles.tutorboy.com/2010/04/01/image-crushing-with-smush-it/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Orkut Style Profile Picture Upload Using jQuery and Ajaxupload</title>
		<link>http://articles.tutorboy.com/2010/03/31/orkut-style-profile-picture-upload-using-jquery-and-ajaxupload/</link>
		<comments>http://articles.tutorboy.com/2010/03/31/orkut-style-profile-picture-upload-using-jquery-and-ajaxupload/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 19:42:40 +0000</pubDate>
		<dc:creator>Midhun Devasia</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Js]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://tutorboy.com/articles/?p=1467</guid>
		<description><![CDATA[We can&#8217;t apply any style over the html file element. But with the help of jQuery and Ajaxupload plugins we ...]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://articles.tutorboy.com/content/uploads/2010/03/orkut_profile_pic.jpg"><img class="alignright size-full wp-image-1469" style="margin: 10px;" title="orkut_profile_pic" src="http://articles.tutorboy.com/content/uploads/2010/03/orkut_profile_pic.jpg" alt="" /></a>We can&#8217;t apply any style over the html <strong><em>file element</em></strong>. But with the help of jQuery and Ajaxupload plugins we can style the <em><strong>file element</strong></em>.  And another alternative solution is to create a <em><strong>file</strong></em> button in Flash. I prefer JavaScript method because its more efficient than flash. Orkut implemented such things in picture uploading section. So I tried to adopt the same style of photo upload from Orkut&#8217;s new theme.</p>
<h3><a class="wp-caption" title="View Demo" href="http://articles.tutorboy.com/content/fileupload/changeImage.php" target="_blank">Vew Demo</a> <a class="wp-caption" href="http://downloads.tutorboy.com/articles/fileupload.zip" target="_blank">Download</a></h3>
<p>In my example, I used the JQuery and Ajaxupload plugin for the development. You can customize this easily. Image replacement with out refreshing your page.</p>
<p><span id="more-1467"></span>Download the <a href="http://docs.jquery.com/Downloading_jQuery" target="_blank">jQuery </a>&amp; <a href="http://valums.com/ajax-upload/" target="_blank">Ajaxupload </a>Js files from the site.</p>
<p>1. Put the jQuery and Ajaxupload into a folder called js or something, and include that in the HTML page.</p>
<h2>HTML:</h2>
<pre class="brush:html">&lt;script type="text/javascript" src="js/jquery.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/ajaxupload.js"&gt;&lt;/script&gt;</pre>
<p>2. Create the image container and other related div and style. Here I have one main DIV called <em>profile_pic </em>and inside that a div with img element having the spinner icon, which is invisible at the first and will active while uploading. Then one more image element for the profile picture. Next is the &#8220;change my photo&#8221; button div.</p>
<h2>HTML:</h2>
<pre class="brush:html">&lt;body&gt;
 &lt;!-- // Container --&gt;
 &lt;div class='profile_pic'&gt;
 &lt;!-- // Spinner --&gt;
 &lt;div id="spinner" style="display:none"&gt;
 &lt;img src="spinner_large.gif" border="0"&gt;
 &lt;/div&gt;
 &lt;!-- // Profile picture --&gt;
 &lt;img src='ep.jpg'  id="profile_img" /&gt;
 &lt;!-- // Button Container --&gt;
 &lt;div class='change_button' id='change_button'&gt;
 &lt;!-- // Button --&gt;
 &lt;div class='change_button_text'&gt;Change my photo&lt;/div&gt;
 &lt;/div&gt;
 &lt;/div&gt;
&lt;/body&gt;</pre>
<p>3. Next is to style the container and other img tags for the better effect with the help of jQuery. Put the following css codes inside the &lt;head&gt; tag.</p>
<h2>CSS:</h2>
<pre class="brush:css">&lt;style type="text/css"&gt;
 div.profile_pic{
 position:relative;
 width:125px;
 }
 div.change_button{
 position:absolute;
 bottom:0px;
 left:0px;
 display:none;
 background-color:black;
 font-family: 'tahoma';
 font-size:11px;
 text-decoration:underline;
 color:white;
 width:125px;
 }
 div.change_button_text{
 padding:10px;
 }
 #spinner{
 position:absolute;
 }
&lt;/style&gt;</pre>
<p>4. Write the JavaScript to enable  <em><strong>file</strong></em> element activities.  There is no physical existence for the <em><strong>file</strong></em> element. But we create this with the help of Ajaxupload plugin.</p>
<h2>JS for  fadein fadeout effect</h2>
<pre class="brush:js">&lt;script type="text/javascript"&gt;
$(window).load(function(){
 // Store the button instance
 var button = $('#change_button');
 // Store the spinner image instance
 var spinner = $('#spinner');

 // Set the opacity to 0...
 button.css('opacity', 0);
 // Set the spinner position as the middle of the profile picture.
 spinner.css('top', ($('.profile_pic').height() - spinner.height()) / 2)
 spinner.css('left', ($('.profile_pic').width() - spinner.width()) / 2)

 // On mouse over those thumbnail
 $('.profile_pic').hover(function() {
 button.css('opacity', .5);
 button.stop(false,true).fadeIn(200);
 },
 function() {
 button.stop(false,true).fadeOut(200);
 });</pre>
<h2>JS for File Element</h2>
<pre class="brush:js">new AjaxUpload(button,{
 action: 'upload.php', // Action page
 name: 'myfile', // file element name
 onSubmit : function(file, ext){
 // Show the spinner while onsubmit
 spinner.css('display', 'block');
 // Yyou can disable upload button
 this.disable();
 },
 // In 'response' variable you will get the value from the upload.php
 onComplete: function(file, response){
 // Set the fadeout value.
 button.stop(false,true).fadeOut(200);
 // remove the Spinner after the upload.
 spinner.css('display', 'none');
 // Assign the new image as the profile picture.
 $('#profile_img').attr('src', response);
 // Enable upload button
 this.enable();
 }
 });

});
&lt;/script&gt;</pre>
<p>5. From the above AjaxUplaod function you can see the action file path &#8220;upload.php&#8221; and &#8220;myfile&#8221; is the file element name. You will get the in php by<strong> $_FILES['myfile']. </strong>The php file should return the image path of the uploaded image.  and the javascipt will receive the name in <strong>response </strong>variable.</p>
<h2>Upload.php</h2>
<pre class="brush:php">&lt;?php
 // Set the upload folder path
 $target_path = "uploads/";
 // Set the new path with the file name
 $target_path = $target_path . basename( $_FILES['myfile']['name']); 

 // Move the file to the upload folder
 if(move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
 /*print the new image path in the page, and this will recevie the javascripts 'response' variable
You can add the resize and other image function here. */
 echo $target_path;
 } else{
 // Set default the image path if any error in upload.
 echo "default.jpg";
 }

?&gt;</pre>
<p>Now its ready to use.</p>
<h2><a class="wp-caption" href="http://articles.tutorboy.com/content/fileupload/changeImage.php" target="_blank">View Demo</a> <a class="wp-caption" href="http://downloads.tutorboy.com/articles/fileupload.zip" target="_blank">Download</a></h2>
]]></content:encoded>
			<wfw:commentRss>http://articles.tutorboy.com/2010/03/31/orkut-style-profile-picture-upload-using-jquery-and-ajaxupload/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

