<?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>Programming Ideas, Logics, Tips and Tricks &#187; php</title>
	<atom:link href="http://www.sajithmr.me/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.sajithmr.me</link>
	<description></description>
	<lastBuildDate>Mon, 23 Jan 2012 15:44:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>New URL Shortener</title>
		<link>http://www.sajithmr.me/new-url-shortener</link>
		<comments>http://www.sajithmr.me/new-url-shortener#comments</comments>
		<pubDate>Fri, 22 Apr 2011 09:50:44 +0000</pubDate>
		<dc:creator>Mr Me</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phurl]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[short url]]></category>

		<guid isPermaLink="false">http://www.sajithmr.me/?p=942</guid>
		<description><![CDATA[I recently started a new URL shortener service. If you&#8217;re bored with old short-url services, you can start using this http://zip.ms Here you can set your-own custom alias, than some random string. I used Phurl library to create this website. I have no spam guard added in the site, please be a real human, I [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" src="http://zip.ms/logo.jpg" alt="" width="240" height="68" /></p>
<p>I recently started a new URL shortener service. If you&#8217;re bored with old short-url services, you can start using this <img src='http://www.sajithmr.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<a href="http://zip.ms">http://zip.ms</a></p>
<p>Here you can set your-own custom alias, than some random string.</p>
<p>I used <a href="http://code.google.com/p/phurl/">Phurl</a> library to create this website.</p>
<p>I have no spam guard added in the site, please be a real human, I trust you <img src='http://www.sajithmr.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&#8211; Sajith</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sajithmr.me/new-url-shortener/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>getId3 &#8211; PHP library for audio contents</title>
		<link>http://www.sajithmr.me/getid3-php-library-for-audio-contents</link>
		<comments>http://www.sajithmr.me/getid3-php-library-for-audio-contents#comments</comments>
		<pubDate>Thu, 06 Jan 2011 15:03:40 +0000</pubDate>
		<dc:creator>Mr Me</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[duration]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[getid3]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[wav]]></category>

		<guid isPermaLink="false">http://www.sajithmr.me/getid3-php-library-for-audio-contents/</guid>
		<description><![CDATA[I recently use getId3 library to manipulate audio files from PHP. It is very accurate than FFMPEG. For example, FFMPEG is not helpful for audio files having VBR (Various Bit Rate). It returns error max_analyze_duration reached OR &#8220;Estimating duration from bitrate, this may be inaccurate&#8221; But by using getId3, we can retrieve detailed information about [...]]]></description>
			<content:encoded><![CDATA[<p style="clear: both">I recently use getId3 library to manipulate audio files from PHP. It is very accurate than FFMPEG. For example, FFMPEG is not helpful for audio files having VBR (Various Bit Rate).</p>
<p style="clear: both">It returns error </p>
<p style="clear: both">max_analyze_duration reached</p>
<p style="clear: both">OR</p>
<p style="clear: both">&#8220;Estimating duration from bitrate, this may be inaccurate&#8221;</p>
<p style="clear: both">But by using getId3, we can retrieve detailed information about a particular audio file (WAV, MP3 or any)</p>
<p style="clear: both">This library can be used for any kind of medias.<br />You can download it from <a href="http://getid3.sourceforge.net/" target="_blank">http://getid3.sourceforge.net/</a></p>
<p style="clear: both">&#8211; Sajith</p>
<p style="clear: both">
<p style="clear: both">
<p><br class="final-break" style="clear: both" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sajithmr.me/getid3-php-library-for-audio-contents/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use OOP in PrOPer way</title>
		<link>http://www.sajithmr.me/use-oop-in-proper-way</link>
		<comments>http://www.sajithmr.me/use-oop-in-proper-way#comments</comments>
		<pubDate>Thu, 30 Sep 2010 20:07:25 +0000</pubDate>
		<dc:creator>Mr Me</dc:creator>
				<category><![CDATA[quick-tips]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[ibm]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[oriented]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.sajithmr.me/use-oop-in-proper-way/</guid>
		<description><![CDATA[Recently I read an article from IBM regarding the usage of Object Oriented Programming in PHP in a proper way. For an average PHP developer, I recommend it is good to read: Read Article Here I also went this link to understand more about abstract class and interface class]]></description>
			<content:encoded><![CDATA[<p style="clear: both">Recently I read an article from IBM regarding the usage of Object Oriented Programming in PHP in a proper way.</p>
<p style="clear: both">For an average PHP developer, I recommend it is good to read:</p>
<p style="clear: both"><a href="http://www.ibm.com/developerworks/opensource/library/os-php-7oohabits/index.html" target="_blank">Read Article Here</a></p>
<p style="clear: both">I also went this <a href="http://www.developer.com/lang/php/article.php/3604111/PHP-5-OOP-Interfaces-Abstract-Classes-and-the-Adapter-Pattern.htm" target="_blank">link</a> to understand more about abstract class and interface class</p>
<p style="clear: both">
<p><br class="final-break" style="clear: both" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sajithmr.me/use-oop-in-proper-way/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Explore a PHP class object</title>
		<link>http://www.sajithmr.me/explore-a-php-class-object</link>
		<comments>http://www.sajithmr.me/explore-a-php-class-object#comments</comments>
		<pubDate>Thu, 30 Sep 2010 02:28:34 +0000</pubDate>
		<dc:creator>Mr Me</dc:creator>
				<category><![CDATA[quicktips]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[explore]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[strip]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.sajithmr.me/explore-a-php-class-object/</guid>
		<description><![CDATA[If you develop website using some framework (Symfony, Codeigniter or Zend etc), you need to play with several system defined objects like routing objects, session objects etc. To see what are the functions available inside an object on run time without referring the parent class documentation, here is a trick: print_r( get_class_methods(get_class($YourObject))); Now you can [...]]]></description>
			<content:encoded><![CDATA[<p style="clear: both"> If you develop website using some framework (Symfony, Codeigniter or Zend etc), you need to play with several system defined objects like routing objects, session objects etc. To see what are the functions available inside an object on run time without referring the parent class documentation, here is a trick:</p>
<p style="clear: both">print_r( get_class_methods(get_class($YourObject)));</p>
<p style="clear: both">Now you can try each functions. This will save a lot of your time without going to the definition.</p>
<p style="clear: both">I use this method, when I develop using symfony to explore an object, eg: $this->getRequest() , to know what are the other functions I can call using this getRequest()</p>
<p style="clear: both">Keep it simple !</p>
<p style="clear: both">&#8211;Sajith</p>
<p><br class="final-break" style="clear: both" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sajithmr.me/explore-a-php-class-object/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symfony 1.4 + Codeigniter  =  Symfony 2</title>
		<link>http://www.sajithmr.me/symfony-1-4-codeigniter-symfony-2</link>
		<comments>http://www.sajithmr.me/symfony-1-4-codeigniter-symfony-2#comments</comments>
		<pubDate>Wed, 08 Sep 2010 15:06:33 +0000</pubDate>
		<dc:creator>Mr Me</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[memory management]]></category>
		<category><![CDATA[new framework]]></category>
		<category><![CDATA[speed]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[symfony1.4]]></category>
		<category><![CDATA[symfony2]]></category>

		<guid isPermaLink="false">http://www.sajithmr.me/?p=853</guid>
		<description><![CDATA[Recently I tried Symfony 2 Sandbox for one of my projects. I realised this fact that Symfony 2 is so powerful because they restructured the Symfony 1.4 architecture and made a system like Codeigniter Framework. I wrote a post some months back about Codeigniter vs Symfony here. I need to re-edit that post now, because, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sajithmr.me/wp-content/uploads/2010/09/Symfony-reloaded.gif"><img class="alignnone size-full wp-image-854" title="Symfony-reloaded" src="http://www.sajithmr.me/wp-content/uploads/2010/09/Symfony-reloaded.gif" alt="" width="400" height="146" /></a></p>
<p>Recently I tried Symfony 2 Sandbox for one of my projects. I realised this fact that Symfony 2 is so powerful because they restructured the Symfony 1.4 architecture and made a system like Codeigniter Framework.</p>
<p>I wrote a post some months back about Codeigniter vs Symfony <a href="http://www.sajithmr.me/symfony-vs-codeigniter" target="_blank">here</a>.</p>
<p>I need to re-edit that post now, because, the drawbacks I mentioned about Symfony (Advantage of Codeigniter over Symfony) is now rectified in Symfony 2.</p>
<p>Symfony was based on naming conventions till 1.4 (like, indexSuccess , deleteSuccess etc) but now in Symfony 2, like Codeigniter   you can mention the name of the view from controller.</p>
<p>The features like view inside view (instead of partials), controller inside view (instead of components) etc are really super in terms of template flexibility.</p>
<p>The Bundle method in Symfony 2 is adapted from the way of codeigniter libraries. (use_library)</p>
<p>The Bundles method also helps in reducing memory conceptions, which Symfony was being blamed for long.</p>
<p>Also the advantages of php 5.3 like namespace, use etc makes Symfony 2 , memory configurable.</p>
<p>The advanced template controller will help to play with any external templating systems very easily. The concept of slot is well used in Symfony 2.</p>
<p>The drastic change in Symfony folder structure will make Symfony developer hard to switch from Symfony 1.4 to 2. But once it is settled, it will be also hard  to go back.</p>
<p>The Symfony team claims that Symfony is faster than any other existing PHP framework available in the market. Must be true !!  But in the <a href="http://symfony-reloaded.org/fast" target="_blank">comparison</a> page,   they avoided Codeigniter.  What could be the reason ?</p>
<p>&#8211; Sajith</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sajithmr.me/symfony-1-4-codeigniter-symfony-2/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Facebook Graph API &#8211; The missing part</title>
		<link>http://www.sajithmr.me/facebook-graph-api-the-missing-part</link>
		<comments>http://www.sajithmr.me/facebook-graph-api-the-missing-part#comments</comments>
		<pubDate>Thu, 15 Jul 2010 08:15:39 +0000</pubDate>
		<dc:creator>Mr Me</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[album]]></category>
		<category><![CDATA[albums]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[empty string]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[graph api]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[missing]]></category>
		<category><![CDATA[permission]]></category>
		<category><![CDATA[photos]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[privacy]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[rest api]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.sajithmr.me/?p=840</guid>
		<description><![CDATA[As you all know recent changes in privacy issues made Facebook to change their basic API and added some security concerns. From my best practise, most of the old applications are safe, but you will be in trouble when you create new application. By default you cannot access user&#8217;s photos, profile pictures , albums etc. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-841" title="facebook_logo" src="http://www.sajithmr.me/wp-content/uploads/2010/07/facebook_logo.png" alt="facebook_logo" width="400" height="132" /></p>
<p>As you all know recent changes in privacy issues made Facebook to change their basic API and added some security concerns. From my best practise, most of the old applications are safe, but you will be in trouble when you create new application. By default you cannot access user&#8217;s photos, profile pictures , albums etc. If you continue with old REST API, you may face this problem. You will get an empty array or json string when you call <strong>photos.getAlbum</strong>s function.</p>
<p>If you test these functions from Facebook Console Tool:</p>
<p><a href="http://developers.facebook.com/docs/reference/rest/photos.getAlbums" target="_blank">http://developers.facebook.com/docs/reference/rest/photos.getAlbums</a></p>
<p>It returns real value when you select old applications and returns empty string [] if you select your newly created Facebook app.</p>
<p>To get all those support, you need to use new <a href="http://developers.facebook.com/docs/api" target="_blank">Graph API</a></p>
<p>But if you follow the same steps mentioned in that official document, you will still get this empty string problem. Because, in the basic authentication call, there is no permission type is mentioned. You can only see a basic message with Allow or Deny button.</p>
<p>According to that document, as the part of authentication, you need to call this url with your client id and redirect url and it returns an access_token after a #</p>
<pre style="margin-top: 18px; margin-right: 18px; margin-bottom: 18px; margin-left: 39px; padding-top: 7px; padding-right: 0px; padding-bottom: 7px; padding-left: 10px; outline-width: 0px; outline-style: initial; outline-color: initial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 3px; border-style: solid; border-color: #d8dfea; line-height: 18px; font-family: monospace; color: #006000; font-size: 13px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f2f2f2; overflow-x: auto; overflow-y: auto; background-position: initial initial; background-repeat: initial initial;">https://graph.facebook.com/oauth/authorize?
    client_id=...&amp;
    redirect_uri=http://www.example.com/oauth_redirect</pre>
<p>You need to use this access_token to request all other functions, eg:</p>
<pre style="margin-top: 18px; margin-right: 18px; margin-bottom: 18px; margin-left: 39px; padding-top: 7px; padding-right: 0px; padding-bottom: 7px; padding-left: 10px; outline-width: 0px; outline-style: initial; outline-color: initial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 3px; border-style: solid; border-color: #d8dfea; line-height: 18px; font-family: monospace; color: #006000; font-size: 13px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f2f2f2; overflow-x: auto; overflow-y: auto; background-position: initial initial; background-repeat: initial initial;">https://graph.facebook.com/me?access_token=...</pre>
<p>This call will work for most of the requests except photos or albums. So the mistake in these calls are the permission.</p>
<p><strong><span style="color: #ff6600;">Here is the correction:</span></strong></p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; margin-top: 18px; margin-right: 18px; margin-bottom: 18px; margin-left: 39px; padding-top: 7px; padding-right: 0px; padding-bottom: 7px; padding-left: 10px; outline-width: 0px; outline-style: initial; outline-color: initial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 3px; line-height: 18px; font-family: monospace; color: #006000; font-size: 13px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f2f2f2; overflow-x: auto; overflow-y: auto; border-color: #d8dfea; border-style: solid;">https://graph.facebook.com/oauth/authorize?
    client_id=...&amp;
    redirect_uri=http://www.example.com/oauth_redirect&amp;perms=publish_stream,user_photos</pre>
<p>Here we pass perms parameter to set different permission and if you use the access_token after this request , you can access user photos and albums. You can see another permission popup with album and photo access.</p>
<p><a href="http://developers.facebook.com/docs/authentication/permissions" target="_blank">Here</a> is the list of such extended permissions in Facebook.</p>
<p>This is the problem when you use new Javascript SDK for graph API, or when you try to integrate these API in PHP or PERL or any other Server side scripting language from the scratch.</p>
<p>If you use new <a href="http://github.com/facebook/php-sdk/" target="_blank">Facebook PHP Graph SDK </a>, you cannot get these problems, but there is still another hidden problem if you continue testing code by the example provided by them.</p>
<p>It is my next POST . See you at there</p>
<p>Thanks</p>
<p>Sajith</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sajithmr.me/facebook-graph-api-the-missing-part/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Facebook Graph API for PHP</title>
		<link>http://www.sajithmr.me/facebook-graph-api-for-php</link>
		<comments>http://www.sajithmr.me/facebook-graph-api-for-php#comments</comments>
		<pubDate>Thu, 15 Jul 2010 05:29:09 +0000</pubDate>
		<dc:creator>Mr Me</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[apt-get]]></category>
		<category><![CDATA[blank page]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[install curl]]></category>
		<category><![CDATA[install json]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[pecl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sdk]]></category>
		<category><![CDATA[solution]]></category>

		<guid isPermaLink="false">http://www.sajithmr.me/?p=845</guid>
		<description><![CDATA[Like the old REST API, you don&#8217;t need to add 2-3 files for Facebook PHP SDK. The new graph api comes in a single file which is located at http://github.com/facebook/php-sdk/ Copy the facebook.php file in to your webroot and include this file in your php code. require_once(&#8216;facebook.php&#8217;); To work fully functional, you need CURL and [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-848" title="php" src="http://www.sajithmr.me/wp-content/uploads/2010/07/php.png" alt="php" width="346" height="226" /></p>
<p>Like the old REST API, you don&#8217;t need to add 2-3 files for Facebook PHP SDK. The new graph api comes in a single file which is located at <a href="http://github.com/facebook/php-sdk/" target="_blank">http://github.com/facebook/php-sdk/</a></p>
<p>Copy the facebook.php file in to your webroot and include this file in your php code.</p>
<p>require_once(&#8216;facebook.php&#8217;);</p>
<p>To work fully functional, you need CURL and JSON installed in your server. To check this use phpinfo() function.</p>
<p>To make sure, these missing is the main problem, add  <span style="color: #00ccff;"><span style="color: #3366ff;">exit(&#8216;Curl error&#8217;)</span>;</span> just above the line   <span style="color: #3366ff;">throw new Exception(&#8216;Facebook needs the CURL PHP extension.&#8217;); <span style="color: #000000;">in facebook.php file.</span></span></p>
<p><span style="color: #3366ff;"><span style="color: #000000;">Same for JSON.</span></span></p>
<p>The Linux way of installing CURL is :</p>
<p><strong>sudo apt-get install curl libcurl3 libcurl3-dev php5-curl</strong></p>
<p>To install JSON in your linux machine, follow <a href="http://slaptijack.com/system-administration/lets-install-json-for-php-5/" target="_blank">these</a> steps:</p>
<ol>
<li><strong>pecl install json</strong></li>
<li>Add json.ini file in /etc/php.d/</li>
<li>edit json.ini (in VI) and add this line: xtension=json.so</li>
<li>Save the file and restart appache (/etc/init.d/httpd restart)  <em>or apache2 restart depends on your linux OS</em></li>
</ol>
<p>See the example.php file in php-sdk from Github, if you call getSession function, you only get a NULL string if you are not logged in proper way. So I recommend to redirect into login page if there is no session available.</p>
<p>Here is the change:</p>
<p>if (! $facebook-&gt;getSession()) {</p>
<p>header(&#8216;Location: &#8216;.$facebook-&gt;getLoginUrl());</p>
<p>}</p>
<p>Then try the rest of the part as per example.php , it will work</p>
<p>Good Luck</p>
<p>Sajith</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sajithmr.me/facebook-graph-api-for-php/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP Session problem with cloud server</title>
		<link>http://www.sajithmr.me/php-session-problem-with-cloud-server</link>
		<comments>http://www.sajithmr.me/php-session-problem-with-cloud-server#comments</comments>
		<pubDate>Thu, 08 Jul 2010 09:51:58 +0000</pubDate>
		<dc:creator>Mr Me</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[$_session]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[empty]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[refresh]]></category>
		<category><![CDATA[saving]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[session not saving]]></category>
		<category><![CDATA[session_save_path]]></category>
		<category><![CDATA[session_start]]></category>

		<guid isPermaLink="false">http://www.sajithmr.me/?p=838</guid>
		<description><![CDATA[There is a very strange issue with PHP session when you prefer session to save in files other than database (normal session). The problem is: some times you can access all the saved session values from $_SESSION and sometimes it returns a empty array. If you refresh 10 times, perhaps 4 times you will get [...]]]></description>
			<content:encoded><![CDATA[<p>There is a very strange issue with PHP session when you prefer session to save in files other than database (normal session).</p>
<p><strong>The problem</strong> is: some times you can access all the saved session values from $_SESSION and sometimes it returns a empty array.</p>
<p>If you refresh 10 times, perhaps 4 times you will get session and 6 times you will get it empty.</p>
<p>The problem is not due to domain level security or session expiry . It is due to session file location. If you run a phpinfo() function in any of your page, you can see there is a part of sessions. There you can see a session variable <strong>session_save_path </strong>and it will be pointing to /tmp/ or /etc/somefolder or /var some folder inside the linux file architecture.</p>
<p>Since at clouds, different servers server at different time, some server can see the exact saved files in that location and some server cannot. (Since /tmp etc directories are not shared among them)</p>
<p><strong>Solution</strong>:  Call the below php function and set session file path inside your web root . You need to call this function before your session_start() call</p>
<p>eg:</p>
<p><strong>session_save_path</strong>(&#8216;/mnt/stor1-wc2-dfw1/4675/5044/to/your/website/rootfolder/or/inner/directory<a style="color: #0000cc;" href="http://research.cicr.com.eg/web/content/'" target="_blank">&#8216;</a>);</p>
<p>For windows users as well, this is the solution. This problem occurs in ASP application as well.</p>
<p>Thanks</p>
<p>Sajith</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sajithmr.me/php-session-problem-with-cloud-server/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>VARDUMP.IT &#8211; PHP remote debugging console</title>
		<link>http://www.sajithmr.me/vardump-it-php-remote-debugging-console</link>
		<comments>http://www.sajithmr.me/vardump-it-php-remote-debugging-console#comments</comments>
		<pubDate>Thu, 10 Jun 2010 23:42:43 +0000</pubDate>
		<dc:creator>Mr Me</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[php source code]]></category>
		<category><![CDATA[webworld]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[vardump]]></category>
		<category><![CDATA[var_dump]]></category>

		<guid isPermaLink="false">http://www.sajithmr.me/?p=833</guid>
		<description><![CDATA[In PHP coding, we spend most of the time for debugging. Either we use echo, print_r or var_dump to check variable values or check whether a particular function is executing or not. These all things are outputting something to browser. This is not applicable in case of redirection, or image processing (GD) or sometimes with [...]]]></description>
			<content:encoded><![CDATA[<p><a href=" http://vardump.it" target="_blank"><img class="alignnone" src="http://vardump.it/images/logo.jpg" alt="" width="206" height="58" /></a></p>
<p>In PHP coding, we spend most of the time for debugging. Either we use echo, print_r or var_dump to check variable values or check whether a particular function is executing or not.</p>
<p>These all things are outputting something to browser. This is not applicable in case of redirection, or image processing (GD) or sometimes with callback url for Payment integrations.</p>
<p>header(Location: etc);may cause Warning : header is already sent , if you put an echo or debug and you cannot  see the output, since it redirects into some other page.</p>
<p>Here is your <strong><span style="color: #993300;">remote debugging console</span></strong> to solve these problems.<a href=" http://vardump.it" target="_blank"> http://vardump.it</a></p>
<p><img class="alignnone size-full wp-image-834" title="remote-console" src="http://www.sajithmr.me/wp-content/uploads/2010/06/remote-console.png" alt="remote-console" width="400" height="320" /></p>
<p>Copy the url from the site and use that url for your debugging purpose and <strong><span style="color: #ff6600;">keep the console open in another tab.</span></strong></p>
<p>eg:</p>
<p>&lt;?php</p>
<p>file_get_contents(&#8216;http://vardump.it/253522/inserted-into-database&#8217;);  // last part of this url is your debugging message</p>
<p>?&gt;</p>
<p>You can see these messages from your remote console http://vardump.it/253522 (last numbers are your unique key)</p>
<p>The debug url is formatted in this way: <span style="text-decoration: underline;"><strong>http://vardump.it/debug-id/your message here</strong></span></p>
<p>Email me for more details.</p>
<p>More features like watch, break etc are under development</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sajithmr.me/vardump-it-php-remote-debugging-console/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Multi-language support with PHP</title>
		<link>http://www.sajithmr.me/multi-language-support-with-php</link>
		<comments>http://www.sajithmr.me/multi-language-support-with-php#comments</comments>
		<pubDate>Sun, 06 Jun 2010 10:28:08 +0000</pubDate>
		<dc:creator>Mr Me</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[arab]]></category>
		<category><![CDATA[engilsh]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[french]]></category>
		<category><![CDATA[hindi]]></category>
		<category><![CDATA[multi]]></category>
		<category><![CDATA[multi-language]]></category>
		<category><![CDATA[multi-langugage support]]></category>
		<category><![CDATA[support]]></category>

		<guid isPermaLink="false">http://www.sajithmr.me/?p=725</guid>
		<description><![CDATA[If you aim to create a multi-language  website using PHP + Mysql , remember the following tips. You can use mysql database for this purpose rather than using separate language files as usual content management system does. You can create a table with following structure for this purpose.Table: muli-lang string_id: page_id: en: arb: fr: Here [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-728" title="multi-language-interface" src="http://www.sajithmr.me/wp-content/uploads/2010/06/multi-language-interface-300x197.jpg" alt="multi-language-interface" width="300" height="197" /></p>
<p>If you aim to create a multi-language  website using PHP + Mysql , remember the following tips.</p>
<ul>
<li>You can use mysql database for this purpose rather than using separate language files as usual content management system does.</li>
<li>You can create a table with following structure for this purpose.Table: muli-lang<br />
string_id:<br />
page_id:<br />
en:<br />
arb:<br />
fr:</li>
<li> Here string_id is the code for getting content  eg: welcome_message<br />
page_id is for saving in which page the content belongs to.  eg: home_page, login_page etc<br />
In field en, you have to enter the message in english,eg: Welcome to my website<br />
In arb field you can enter the corresponding translation in arab. eg: مرحبا بكم في موقعي</li>
<li>If you need to add more languages, it is just adding one more column to this table and put all translated values.</li>
<li>Write a class or functions in PHP to retrieve all the informations.<br />
eg: function get(language_id, page_id) returns corresponding message</li>
<li>Use session to save lang value. For example if you switch to french, set a variable lang= fr and use this variable to decide which column is to access from multi-lang table.eg: the sql will be , SELECT $lang FROM multi-lang WHERE string_id = &#8216;welcome_message&#8217;</li>
<li>For some string fragment like about_us, contact_us etc, it has global scope; then leave page_id as blank</li>
<li>To avoid multiple calling of functions to get translation, write a common function to get all translation for a particular page_id as array, and use this array all through the page. Thus you can avoid mysql query multiple times.<br />
eg: function get_all($page_id) returns array, say $Translate of all strings replacement. $Translate['login_message'], $Translate['login_error']</li>
<li>Additional things to remember:</li>
<li>Use this meta tab in html header<br />
<span style="color: #993300;">&lt;</span><em><span style="color: #993300;">meta</span></em><span style="color: #993300;"> http-equiv=&#8221;Content-Type&#8221; content=&#8221;text /</span><em><span style="color: #993300;">html</span></em><span style="color: #993300;">; charset=</span><em><span style="color: #993300;">UTF-8</span></em><span style="color: #993300;">&#8221; /&gt;</span><br />
to show all languages</li>
<li>Create my_sql table in UTF-8 format</li>
<li>Execute the following query before executing any retrieval queries. Otherwise you may get ????? for language like Arabic, Hindi, Chinese etc.<br />
<span style="color: #333399;">mysql_query(&#8220;SET CHARACTER SET &#8216;utf8&#8242;&#8221;, $link);</span></li>
</ul>
<p>I hope these information may help you when you develop a multi-langauge support website</p>
<p>Thank you<br />
Sajith</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sajithmr.me/multi-language-support-with-php/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

