<?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>Samet Kilictas&#039;s Blog &#187; php</title>
	<atom:link href="http://samet.kilictas.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://samet.kilictas.com</link>
	<description>J2E, PHP, Linux, PL/SQL and other random rants</description>
	<lastBuildDate>Sun, 06 Nov 2011 04:36:58 +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>Cannot load mysqli extension. Please check your PHP configuration</title>
		<link>http://samet.kilictas.com/cannot-load-mysqli-extension-please-check-your-php-configuration/</link>
		<comments>http://samet.kilictas.com/cannot-load-mysqli-extension-please-check-your-php-configuration/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 14:01:28 +0000</pubDate>
		<dc:creator>Samet Kilictas</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[IIS7]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[WAMP]]></category>
		<category><![CDATA[WampServer]]></category>

		<guid isPermaLink="false">http://samet.kilictas.com/?p=364</guid>
		<description><![CDATA[Probably you are trying to access your phpmyadmin. You will get this error  if you have more then one &#8220;php.ini&#8221; file in your system. It is kinda conflicting. For instance i have wampserver2.0 and IIS7 together in my current system. I have activated IIS7 FastCgı method to use php on it. So it has one [...]]]></description>
			<content:encoded><![CDATA[<p>Probably you are trying to access your phpmyadmin. You will get this error  if you have more then one &#8220;php.ini&#8221; file in your system. It is kinda conflicting. For instance i have wampserver2.0 and IIS7 together in my current system. I have activated IIS7 FastCgı method to use php on it. So it has one php.ini file at path of  &#8220;c:\wamp\&#8230;.&#8221; and another one in &#8220;c:\Program Files\Php&#8221; . You can get a temporary solution if you rename your php.ini file which is in your &#8220;program files&#8221; path.</p>
<p>That is it.</p>
<a href='http://twitter.com/share?url=http%3A%2F%2Fsamet.kilictas.com%2F%3Fp%3D364&count=vertical&related=&text=Cannot%20load%20mysqli%20extension.%20Please%20check%20your%20PHP%20configuration' class='twitter-share-button' data-text='Cannot load mysqli extension. Please check your PHP configuration' data-url='http://samet.kilictas.com/?p=364' data-counturl='http://samet.kilictas.com/cannot-load-mysqli-extension-please-check-your-php-configuration/' data-count='vertical' data-via='sametkilictas'>Tweet</a>]]></content:encoded>
			<wfw:commentRss>http://samet.kilictas.com/cannot-load-mysqli-extension-please-check-your-php-configuration/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Gedit Modifications for PHP</title>
		<link>http://samet.kilictas.com/gedit-modifications-for-php/</link>
		<comments>http://samet.kilictas.com/gedit-modifications-for-php/#comments</comments>
		<pubDate>Sun, 17 May 2009 11:37:06 +0000</pubDate>
		<dc:creator>Samet Kilictas</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[gedit]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://samet.kilictas.com/?p=314</guid>
		<description><![CDATA[Since i am coding with codeigniter framework on gedit, i was looking for snippets for codeigniter on gedit download gedit snippet for codeigniter By the way if you want to make your gedit more useful for programming surely you may add some third party plugins as many as you want or simply just active default [...]]]></description>
			<content:encoded><![CDATA[<p>Since i am coding with codeigniter framework on gedit, i was looking for snippets for codeigniter on gedit</p>
<p><a href="http://samet.kilictas.com/wp-content/uploads/2009/05/php.xml">download gedit snippet for codeigniter</a></p>
<p>By the way if you want to make your gedit more useful for programming surely you may add some third party plugins as many as you want or simply just active default plugins.  Idea is that firstly download a plugin then extract its content to ‘~/.gnome2/gedit/plugins/’  directory. Once you have installed the plugin you want, you need to enable it via Edit&gt;Preferences and then the Plugins Tab. Such as;</p>
<blockquote><p>- Snippets<br />
- Class Browser<br />
- Bracket Completation<br />
- Character Map<br />
- Embedded Terminal<br />
etc..</p></blockquote>
<p>You can basicly find out third-party plugins by clicking on <a href="http://live.gnome.org/Gedit/Plugins#third_party">this link</a></p>
<a href='http://twitter.com/share?url=http%3A%2F%2Fsamet.kilictas.com%2F%3Fp%3D314&count=vertical&related=&text=Gedit%20Modifications%20for%20PHP' class='twitter-share-button' data-text='Gedit Modifications for PHP' data-url='http://samet.kilictas.com/?p=314' data-counturl='http://samet.kilictas.com/gedit-modifications-for-php/' data-count='vertical' data-via='sametkilictas'>Tweet</a>]]></content:encoded>
			<wfw:commentRss>http://samet.kilictas.com/gedit-modifications-for-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>What is PHP?</title>
		<link>http://samet.kilictas.com/what-is-php/</link>
		<comments>http://samet.kilictas.com/what-is-php/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 09:24:37 +0000</pubDate>
		<dc:creator>Samet Kilictas</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[what is php]]></category>

		<guid isPermaLink="false">http://samet.kilictas.com/?p=273</guid>
		<description><![CDATA[First of all i need to say that PHP is a language which you are going to in love with. (That is of course if you are a developer ) PHP stands for PHP: Hypertext Processsor. To start with it you should have knowledge about basic scripting and HTML language. PHP is totaly free to [...]]]></description>
			<content:encoded><![CDATA[<p>First of all i need to say that PHP is a language which you are going to in love with. (That is of course if you are a developer ) <strong>PHP </strong>stands for <strong>P</strong>HP: <strong>H</strong>ypertext <strong>P</strong>rocesssor.</p>
<p>To start with it you should have knowledge about basic scripting and HTML language.</p>
<p>PHP is totaly free to use and download that is because it is an open source. Well there are many scripting languages on the earth. PHP is server-side scripting language. It means codes are executing on the server-side not in the client-side.</p>
<p style="text-align: center;"><a href="http://samet.kilictas.com/wp-content/uploads/2009/04/server-side-php.gif"><img class="alignnone size-medium wp-image-274" title="server-side-php" src="http://samet.kilictas.com/wp-content/uploads/2009/04/server-side-php-276x300.gif" alt="" width="276" height="300" /></a></p>
<p>Thus, clients cannot see your php script, a client can only see pure html content. Now i can say PHP is secure langauge since user cannot see your PHP code. How it works? For instance, a client (user) requests a webpage from your server. Then your server executes php code and returns pure html content to the user. And user have no chance to see what is going on at the server-side.</p>
<p><em>Extensions : .php, .php3, .phtml</em></p>
<p><span id="more-273"></span></p>
<p><strong>Why PHP?</strong></p>
<p>It works efficiently on server-side. PHP language supports many database programs such as MySQL, ISS, Informix, Oracle, Sybase, Solid,   PostgreSQL, Generic ODBC, etc. And yes it is cross-platform. It runs on many-platforms MacOS, Windows, Linux, Unix, etc. and compatible with almost all servers.</p>
<p>I will keep writing on PHP topic with more details.</p>
<a href='http://twitter.com/share?url=http%3A%2F%2Fsamet.kilictas.com%2F%3Fp%3D273&count=vertical&related=&text=What%20is%20PHP%3F' class='twitter-share-button' data-text='What is PHP?' data-url='http://samet.kilictas.com/?p=273' data-counturl='http://samet.kilictas.com/what-is-php/' data-count='vertical' data-via='sametkilictas'>Tweet</a>]]></content:encoded>
			<wfw:commentRss>http://samet.kilictas.com/what-is-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Let&#8217;s get started with jQuery</title>
		<link>http://samet.kilictas.com/lets-get-started-with-jquery/</link>
		<comments>http://samet.kilictas.com/lets-get-started-with-jquery/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 11:37:24 +0000</pubDate>
		<dc:creator>Samet Kilictas</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Jquery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://samet.kilictas.com/?p=247</guid>
		<description><![CDATA[Nowadays you may see tons of Javascript frameworks coming up. The truth is that it makes your code efficient if a framework used instead of pure javascript code. Most of the javascript frameworks helps you to solve crossbrowser difficulties. Probably you heard about Prototype and MooTools. You may see some people are trying to decide [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://samet.kilictas.com/wp-content/uploads/2009/02/logo_jquery_215x53.gif"><img class="alignleft size-full wp-image-248" title="Jquery" src="http://samet.kilictas.com/wp-content/uploads/2009/02/logo_jquery_215x53.gif" alt="" width="215" height="53" /></a> Nowadays you may see tons of Javascript frameworks coming up. The truth is that it makes your code efficient if a framework used instead of pure javascript code. Most of the javascript frameworks helps you to solve crossbrowser difficulties. Probably you heard about Prototype and MooTools. You may see some people are trying to decide between these frameworks. I should say i am fan of jQuery. jQuery comes with tons of futures and flexibility and you can do a big work with less effort and it is not just a regular library however jQuery is even ajax and effect library. It does evertything i need with piece of code.</p>
<blockquote><p>jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.</p></blockquote>
<p>Let&#8217;s say you are using some other libraries as well, there it goes, jQuery is such a good friend with other libraries. API designed with conciseness and convenience as the driving factors.</p>
<p>Before start with jQuery i want you to know some basics about it. You can download the framework basically from www.jquery.com then download it on your desktop. This is how jQuery places in html code.</p>
<pre class="brush: html">&lt;html&gt;
&lt;head&gt;
&lt;strong&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt;&lt;/strong&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;strong&gt;// Your code goes here&lt;/strong&gt;
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;a href=&quot;http://jquery.com/&quot;&gt;jQuery&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>You can start with placing your core *.js file which is jquery.js for this example.</p>
<p><span id="more-247"></span></p>
<p><code>&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;</code></p>
<p>You may change src attribute to point your js files in your server path. Once you done with it then you can start with jquery. Now all you should do is place your code in &#8220;// Your code goes here&#8221; part.</p>
<a href='http://twitter.com/share?url=http%3A%2F%2Fsamet.kilictas.com%2F%3Fp%3D247&count=vertical&related=&text=Let%26%23039%3Bs%20get%20started%20with%20jQuery' class='twitter-share-button' data-text='Let&#039;s get started with jQuery' data-url='http://samet.kilictas.com/?p=247' data-counturl='http://samet.kilictas.com/lets-get-started-with-jquery/' data-count='vertical' data-via='sametkilictas'>Tweet</a>]]></content:encoded>
			<wfw:commentRss>http://samet.kilictas.com/lets-get-started-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embed php into Javascript</title>
		<link>http://samet.kilictas.com/embed-php-into-javascript/</link>
		<comments>http://samet.kilictas.com/embed-php-into-javascript/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 23:43:49 +0000</pubDate>
		<dc:creator>Samet Kilictas</dc:creator>
				<category><![CDATA[Jquery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[$(document)]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://samet.kilictas.com/?p=236</guid>
		<description><![CDATA[In javascript you cannot read variables from a server instanly however if you embed your php code you may pass variables into javascript code. So php can pass its variables when page loads. Here is an example using jquery &#60;?php $variable = &#039;Here is value&#039;; ?&#62; &#60;script type= &#34;text/javascript&#34;&#62; $(document).ready(function(){ var button = &#60;?php echo [...]]]></description>
			<content:encoded><![CDATA[<p>In javascript you cannot read variables from a server instanly however if you embed your php code you may pass variables into javascript code.</p>
<p>So php can pass its variables when page loads. Here is an example using jquery</p>
<pre class="brush: php">&lt;?php $variable = &#039;Here is value&#039;; ?&gt;
&lt;script type= &quot;text/javascript&quot;&gt;
$(document).ready(function(){
var button = &lt;?php echo $variable; ?&gt; ;
});
&lt;/script&gt;
</pre>
<p><span id="more-236"></span>Keep Coding</p>
<a href='http://twitter.com/share?url=http%3A%2F%2Fsamet.kilictas.com%2F%3Fp%3D236&count=vertical&related=&text=Embed%20php%20into%20Javascript' class='twitter-share-button' data-text='Embed php into Javascript' data-url='http://samet.kilictas.com/?p=236' data-counturl='http://samet.kilictas.com/embed-php-into-javascript/' data-count='vertical' data-via='sametkilictas'>Tweet</a>]]></content:encoded>
			<wfw:commentRss>http://samet.kilictas.com/embed-php-into-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeIgniter How to Pagination</title>
		<link>http://samet.kilictas.com/codeigniter-how-to-pagination/</link>
		<comments>http://samet.kilictas.com/codeigniter-how-to-pagination/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 08:53:02 +0000</pubDate>
		<dc:creator>Samet Kilictas</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[CodeIgniter pagination]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[pagination class]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://samet.kilictas.com/?p=101</guid>
		<description><![CDATA[CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. If you&#8217;re a developer who lives in the real world of shared hosting accounts and clients with deadlines, and if you&#8217;re tired of ponderously large and thoroughly undocumented [...]]]></description>
			<content:encoded><![CDATA[<p>CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. If you&#8217;re a developer who lives in the real world of shared hosting accounts and clients with deadlines, and if you&#8217;re tired of ponderously large and thoroughly undocumented frameworks.</p>
<p>CodeIgniter&#8217;s Pagination class is very easy to use, and it is 100% customizable, either dynamically or via stored preferences.</p>
<p>If you are not familiar with the term &#8220;pagination&#8221;, it refers to links that allows you to navigate from page to page, like this:</p>
<p><code><a href="http://localhost/cms/user_guide/libraries/pagination.html#">« First</a> <a href="http://localhost/cms/user_guide/libraries/pagination.html#">&lt;</a> <a href="http://localhost/cms/user_guide/libraries/pagination.html#">1</a> <a href="http://localhost/cms/user_guide/libraries/pagination.html#">2</a> <strong>3</strong> <a href="http://localhost/cms/user_guide/libraries/pagination.html#">4</a> <a href="http://localhost/cms/user_guide/libraries/pagination.html#">5</a> <a href="http://localhost/cms/user_guide/libraries/pagination.html#">&gt;</a> <a href="http://localhost/cms/user_guide/libraries/pagination.html#">Last »</a></code></p>
<pre class="brush: php">
function shownews()
{
if($this-&gt;userlib-&gt;logged_in())
//checking for security purposes
{
$this-&gt;load-&gt;library(&#039;pagination&#039;);
$per_page = 10;
// How many pages you want to show in each page
$total = $this-&gt;db-&gt;get(&#039;posts&#039;, $per_page, $this-&gt;uri-&gt;segment(3)); 

//Here is the most important part actually.
Basically $total variable determined which
rows you are going to show in the page

$config[&#039;base_url&#039;] = base_url().&#039;/index.php/admin/shownews&#039;;
$config[&#039;total_rows&#039;] = $this-&gt;db-&gt;count_all(&#039;posts&#039;); // Count total rows in the query
$config[&#039;per_page&#039;] = $per_page;
$config[&#039;num_links&#039;] = 6;
$this-&gt;pagination-&gt;initialize($config);
$data[&#039;posts&#039;] = $total;
$this-&gt;load-&gt;view(&#039;admin_shownews&#039;, $data);
} else {
$this-&gt;load-&gt;view(&#039;admin_logineed&#039;);
}
}
</pre>
<p>After getting done with this configuration part of pagination class all you have to do is just initialize it like you are doing it in most of programming languages.</p>
<p><span id="more-101"></span></p>
<p>Then by using $this-&gt;load-&gt;view()  parse your data array to your view which is going to be used for showing paginated items. In that view page you should use this;</p>
<pre class="brush: php">&lt;?php echo $this-&gt;pagination-&gt;create_links(); ?&gt;</pre>
<p>to auto create your pagination links. You can put this anwhere in your page you want.</p>
<a href='http://twitter.com/share?url=http%3A%2F%2Fsamet.kilictas.com%2F%3Fp%3D101&count=vertical&related=&text=CodeIgniter%20How%20to%20Pagination' class='twitter-share-button' data-text='CodeIgniter How to Pagination' data-url='http://samet.kilictas.com/?p=101' data-counturl='http://samet.kilictas.com/codeigniter-how-to-pagination/' data-count='vertical' data-via='sametkilictas'>Tweet</a>]]></content:encoded>
			<wfw:commentRss>http://samet.kilictas.com/codeigniter-how-to-pagination/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A simple password generator</title>
		<link>http://samet.kilictas.com/a-simple-password-generator/</link>
		<comments>http://samet.kilictas.com/a-simple-password-generator/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 23:04:57 +0000</pubDate>
		<dc:creator>Samet Kilictas</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[online password genetator]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://samet.kilictas.com/?p=64</guid>
		<description><![CDATA[You are going to need this for sure : ) function generatePassword($length=9, $strength=0) { $vowels = &#039;aeuy&#039;; $consonants = &#039;bdghjmnpqrstvz&#039;; if ($strength &#38;amp; 1) { $consonants .= &#039;BDGHJLMNPQRSTVWXZ&#039;; } if ($strength &#38;amp; 2) { $vowels .= &#34;AEUY&#34;; } if ($strength &#38;amp; 4) { $consonants .= &#039;23456789&#039;; } if ($strength &#38;amp; 8 ) { $consonants .= [...]]]></description>
			<content:encoded><![CDATA[<p>You are going to need this for sure : )</p>
<pre class="brush: php">
function generatePassword($length=9, $strength=0) {
$vowels = &#039;aeuy&#039;;
$consonants = &#039;bdghjmnpqrstvz&#039;;
if ($strength &amp;amp; 1) {
$consonants .= &#039;BDGHJLMNPQRSTVWXZ&#039;;
}
if ($strength &amp;amp; 2) {
$vowels .= &quot;AEUY&quot;;
}
if ($strength &amp;amp; 4) {
$consonants .= &#039;23456789&#039;;
}
if ($strength &amp;amp; 8 ) {
$consonants .= &#039;@#$%&#039;;
}

$password = &#039;&#039;;
$alt = time() % 2;
for ($i = 0; $i &amp;lt; $length; $i++) {
if ($alt == 1) {
$password .= $consonants[(rand() % strlen($consonants))];
$alt = 0;
} else {
$password .= $vowels[(rand() % strlen($vowels))];
$alt = 1;
}
}
return $password;
}</pre>
<p>and..<br />
<span id="more-64"></span></p>
<p>all you have to do is change the values which are $length=9, $strength=0 then you are going to have a password which is stenght and long : )</p>
<a href='http://twitter.com/share?url=http%3A%2F%2Fsamet.kilictas.com%2F%3Fp%3D64&count=vertical&related=&text=A%20simple%20password%20generator' class='twitter-share-button' data-text='A simple password generator' data-url='http://samet.kilictas.com/?p=64' data-counturl='http://samet.kilictas.com/a-simple-password-generator/' data-count='vertical' data-via='sametkilictas'>Tweet</a>]]></content:encoded>
			<wfw:commentRss>http://samet.kilictas.com/a-simple-password-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coding Guidelines For Developers</title>
		<link>http://samet.kilictas.com/coding-guidelines-for-developers/</link>
		<comments>http://samet.kilictas.com/coding-guidelines-for-developers/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 10:57:31 +0000</pubDate>
		<dc:creator>Samet Kilictas</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Samet]]></category>

		<guid isPermaLink="false">http://samet.kilictas.com/?p=62</guid>
		<description><![CDATA[@author andrej arn @author sam blume @version 4.6 updated 2005-11-24 Basically&#8230; we&#8217;d like to have a clean and professional, bug-free code. Most people have different coding styles. And most think that &#8220;the other style&#8221; is ugly. We don&#8217;t want to force you changing your style. Here is how we do it and like it: o) [...]]]></description>
			<content:encoded><![CDATA[<p><strong>@author andrej arn<br />
@author sam blume<br />
@version 4.6 updated 2005-11-24</strong></p>
<p>Basically&#8230;<br />
we&#8217;d like to have a clean and professional, bug-free code.<br />
Most people have different coding styles. And most think that<br />
&#8220;the other style&#8221; is ugly. We don&#8217;t want to force you changing<br />
your style. Here is how we do it and like it:</p>
<p>o) We use capital letters for constants. e.g. define(&#8216;CONSTANT&#8217;, 1).<br />
We also use the capital form of  TRUE, FALSE and NULL.<br />
This is true for PHP, note that javascript needs lowercase.</p>
<p>o) If a function is described to return bool, expect to get a real bool<br />
(TRUE/FALSE) and not an int (0/1). So please code your functions and<br />
methods that way.</p>
<p>o) Don&#8217;t trust the return values from php methods. If they are stated<br />
to return bool, they often return an int (0/1). So don&#8217;t directly<br />
return that from your functions, convert to (bool) if necessary.</p>
<p>o) Never ever use echo, print and die and the like inside your methods.<br />
Use return.</p>
<p>o) this applies also for white spaces. if you start your file with anything<br />
(an empty line) before the     considered as output. This makes header() calls impossible (cookie,<br />
session). The same applies for white spaces after the ?&gt; tag. take care!<br />
Even a newline is too much. This is a typical php newbie mistake.</p>
<p>o) Everything should be as os independant as possible. Including windows.</p>
<p>o) Make your code work with PHP version 4.3.0+ and 5.0.5+.<br />
Don&#8217;t support php3.</p>
<p>o) Make the php exam. Repeat it from time to time.</p>
<p>http://www.blueshoes.org/en/developer/syntax_exam/</p>
<p><span id="more-62"></span></p>
<p>o) Code object oriented. (PHP4)</p>
<p>o) Avoid setting vars in the global scope. If you need one, prefix it.<br />
Example: $GLOBALS['_Bs_MyClass_MyVar'] = &#8216;foo&#8217;;</p>
<p>o) Avoid using things from global scope inside methods. Instead &#8216;include&#8217;<br />
them in the constructor.</p>
<p>o) Prefix classes with Bs_. This is a poor man&#8217;s namespace.</p>
<p>o) Name your files like the classes: a class named &#8216;Bs_Something&#8217; will<br />
have the file name &#8216;Bs_Something.class.php&#8217;.</p>
<p>o) One class per file.</p>
<p>o) References:<br />
Don&#8217;t return temporaries by reference.<br />
function &amp;foo() {<br />
return new StdClass(); //this is wrong<br />
return $ret = new StdClass(); //this is wrong too</p>
<p>//this is wrong too. (it works at least in php 4.4.1,<br />
//but who knows, it&#8217;s inconsistent, so please don&#8217;t use it.)<br />
return $ret =&amp; new StdClass();</p>
<p>$ret =&amp; new StdClass(); return $ret; //this is right<br />
return FALSE; //this is wrong<br />
return $ret = FALSE; //this is wrong<br />
$ret = FALSE; return $ret; //this is right<br />
$classOne =&amp; new StdClass();<br />
$classTwo =&amp; new StdClass();<br />
return (true) ? $classOne : $classTwo; //this is wrong<br />
}<br />
$object =&amp; foo();</p>
<p>Don&#8217;t pass temporaries by reference:<br />
function foo(&amp;$param) {}<br />
foo(TRUE); //this is wrong<br />
$param = TRUE; foo($param); //this is wrong</p>
<p>//this is wrong. (it works, but who knows, it&#8217;s inconsistent,<br />
//so please don&#8217;t use it.)<br />
foo(new StdClass);</p>
<p>$param =&amp; new StdClass(); foo($param); //this is right</p>
<p>Also take care when encapsulating functions:<br />
function foo() { return new StdClass(); }<br />
function bar(&amp;$param) {}<br />
bar(foo()); //this is wrong<br />
$object = foo(); bar($object); //this is right</p>
<p>When you create a new instance of a class, *always* do it by reference:<br />
$object =&amp; new SomeClass();<br />
^&#8212;-&gt;this one<br />
This is *important*, *important*, *important*!!. Trust me. if you don&#8217;t,<br />
you will after having strange bugs in your code and not finding them<br />
for hours.<br />
Also read http://www.zend.com/manual/language.oop.newref.php please.</p>
<p>o) Please use the same coding style as it is already used, if you can.<br />
I know that changing your coding style is not easy if you&#8217;re used to<br />
something.</p>
<p>old: &#8211; a tab is 2 spaces<br />
new: &#8211; a tab is a tab, we set it to the width of 2, but feel free to<br />
configure your editor to show it as 3, 4, 8, whatever.</p>
<p>- A function is written like:<br />
function something(param, param) {<br />
//some code<br />
}</p>
<p>- An if statement is written like:<br />
if ($this == $that) {<br />
} elseif ($this &gt; $that) {<br />
} else {<br />
}</p>
<p>- Use spaces to separate:<br />
$x .= $y . &#8216;hello&#8217;;   instead of   $x.=$y.&#8217;hello&#8217;;<br />
exceptions are (for readability):<br />
- $array = array(&#8216;key&#8217;=&gt;&#8217;value&#8217;, &#8216;key2&#8242;=&gt;&#8217;value2&#8242;);<br />
- for ($i=1; $i&lt;=10; $i++) {<br />
- function myFunction($a=&#8217;default&#8217;, $b=&#8217;foobar&#8217;) {</p>
<p>o) Naming conventions:</p>
<p>- PHP itself is *very* inconsistent about the naming:<br />
isset() but is_string() =&gt; underscore or not,<br />
strtolower but bin2hex =&gt; to or 2,<br />
create_function but str_shuffle =&gt; verb object, object verb,<br />
strpos(haystack, needle) but in_array(needle, haystack) =&gt; order of param<br />
so let&#8217;s do it better.</p>
<p>- Use studly caps (first letter of each word capitalized (but not the<br />
first one), otherwise lower case, no underscores) for vars, functions<br />
(methods), lists, anything that needs a unique name.<br />
class names go like &#8216;Bs_SomeClass&#8217;.<br />
vars/functions/objects/db-names are started lowercase, class<br />
names/db-table names are started uppercase:<br />
$someVarName         instead of   $some_var_name<br />
someFunctionName()   instead of   some_function_name()<br />
SomeObject           instead of   some_object<br />
this especially also applies for short forms:<br />
$someDbTable         instead of   $someDBTable<br />
$someHtmlString      instead of   $someHTMLString</p>
<p>It is easier to read, and you can be sure how it was written. We think<br />
it&#8217;s better from experience. (An exception is the table field name/term<br />
ID because of a naming convention.)</p>
<p>Often it is hard to decide if a word is made up of multiple words.</p>
<p>These words are considered being one word, not two, and thus have<br />
no capital:<br />
- username  (not userName)<br />
- password  (not passWord)<br />
- blueshoes (not blueShoes)</p>
<p>These words are considered being two words and thus have a capital:<br />
- fileName (not filename)<br />
- passPhraze (not passphraze)<br />
- dateTime  (not datetime)</p>
<p>A few other writings:<br />
- email    (not eMail or so, because someEmail will work while<br />
someeMail or someEmail or someEMail would break the rules.)</p>
<p>Please avoid something like &#8216;$conn1&#8242; (&#8216;$conn2&#8242;, &#8216;$conn3&#8242; &#8230;) because<br />
you cannot see if it was $conn1 or $connl. See what i mean? (one or<br />
a small L, depending on the font)</p>
<p>- Don&#8217;t use the fancy way pdf2html. It&#8217;s kinda breaking the studly<br />
caps rule. it would be pdf2Html and then it&#8217;s not that readable<br />
anymore because both &#8217;2&#8242; and &#8216;H&#8217; are &#8220;upper case&#8221;. So always use<br />
pdfToHtml.</p>
<p>- Use verb object, not object verb. So makeObject(), not objectMake().</p>
<p>- If in doubt, use java syntax/style.</p>
<p>o) Learn the difference between == and === and != and !==. Read the manual<br />
and check http://www.blueshoes.org/en/developer/php_cheat_sheet/</p>
<p>o) Passing by reference: Our code needs to be compatible with PHP 4 and 5.<br />
PHP5 passes all objects by reference while PHP4 passes them by copy.<br />
To make both versions behave the same way, do the following:<br />
To pass by reference (99% of all cases):<br />
function foo(&amp;$theObject, $theInteger) {<br />
&#8230;<br />
}<br />
foo($someObject, 5);<br />
To pass by value (1% of all cases):<br />
function foo($theObject, $theInteger) {<br />
&#8230;<br />
}<br />
$copyOfObject = bs_clone($someObject);<br />
foo($copyOfObject, 5);</p>
<p>o) Private vars and methods start with an underscore.<br />
_foo is a private var, foo is a public var, _foo() is a private method<br />
and foo() a public one.</p>
<p>o) In your classes, define all your public and private class vars using<br />
var $something; or var $_something;<br />
even if you don&#8217;t set a default value. It will help maintaining the code.</p>
<p>o) Document while you code. Please document (phpdoc, like javadoc) your<br />
functions, classes, methods, even class vars. I know that coders are<br />
always in a hurry. But it will save a lot of time in the end!</p>
<p>It looks like this:<br />
/**<br />
* What the function does in one line.<br />
* Here goes some more detailed description on 0-n lines, if needed.<br />
* @access  [public|static|pseudostatic]<br />
* @param   [string|int|double|bool|array|object|mixed] $paramName desc<br />
* @return  datatype  description<br />
* @throws  [bs_exception|bool FALSE|NULL...]<br />
* @see     someFunction(), var someVar<br />
* @todo    description<br />
* @since   bs4.1, php4.3             (comma separated list)<br />
* @status  stable|experimental       (if not set then considered stable)<br />
* @pattern singleton|factory|mvc|observer|facade|&#8230;<br />
*/<br />
function something() {<br />
}</p>
<p>For variables the @var keyword is used instead of @param:<br />
/**<br />
* Some internally used var.<br />
* @access private<br />
* @var    bool $someStatus<br />
* @see    setSomeStatus()<br />
*/<br />
var $_someStatus = FALSE;</p>
<p>The description may include HTML, but please avoid it on the first line.</p>
<p>#@pattern singleton means that the constructor returns a reference<br />
#to an already existing instance, if there is one.</p>
<p>o) Write ecg classes for your code. They will serve other coders<br />
as examples and make the code more safe. Especially when it is<br />
installed on other os&#8217;es, when new php/apache/mysql/&#8230; versions come<br />
out etc. See naming for a definition of ecg.<br />
The classes are in subfolders named &#8216;ecg&#8217;, for an example have a look<br />
at core/util/ecg/Bs_String_PhpUnit.class.php</p>
<p>o) Don&#8217;t eat junk food and never drink Red Bull at night. Pizza is ok. <img src='http://samet.kilictas.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>o) Don&#8217;t use underscores _ in databases (table names, field names).<br />
They are reserved for relations (foreign key by naming convention).<br />
Don&#8217;t use the numbers 2, 3 and 4 inside of db table names. They are<br />
reserved for the same reason.</p>
<p>o) Associative arrays are called &#8216;hash&#8217;, zero-based arrays are called<br />
&#8216;vector&#8217;. Please use these terms. Undefined arrays are called &#8216;array&#8217;.</p>
<p>o) Use the term &#8216;function&#8217; for &#8216;structured&#8217; procedural code. Use the term<br />
&#8216;method&#8217; for functions inside classes. Don&#8217;t use the terms &#8216;procedures&#8217;,<br />
&#8216;subs&#8217;, &#8216;routines&#8217; etc.<br />
sam: &#8220;methods are verbs, classes are substantives.&#8221; <img src='http://samet.kilictas.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>o) When you return inside a switch or something, write the break too.<br />
example:<br />
switch ($x) {<br />
case &#8216;hello&#8217;:<br />
return TRUE;<br />
break;<br />
}<br />
This way it will be harder for someone to &#8216;implement&#8217; bugs into your code.</p>
<p>o) Avoid buggy code. For example if you&#8217;re not 100% sure that a var is<br />
an array, do is_array(), sizeOf($array) and such.</p>
<p>o) To be PHP4 compatible instead of using try-catch use the do-while(FALSE)<br />
try-catch code, something like:<br />
do { // try block<br />
$isOk = someFunction();<br />
if (!$isOk) break;<br />
$isOk = otherFunction();<br />
if (!$isOk) break;<br />
//&#8230;<br />
$isOk = TRUE; //everything worked<br />
} while (FALSE);<br />
if ($isOk) echo &#8216;yeah&#8217;;</p>
<p>o) Form your var declaration blocks etc in a nice way: (note the extra<br />
spaces)<br />
$a        = &#8216;hello&#8217;;<br />
$bbbb     = &#8216;world&#8217;;<br />
$cccccccc = &#8216;foobar&#8217;;</p>
<p>o) Mostly use foreach instead of while-list to loop arrays. See sam&#8217;s<br />
php-bench: http://www.blueshoes.org/en/developer/php_bench/</p>
<p>Note: there are also, and i like them (andrej)<br />
while (list($k,) = each($a)) {<br />
while (list(,$v) = each($a)) {</p>
<p>o) Magic_quotes_gpc was a good idea to prevent sql injection.<br />
Unfortunately this feature can be turned on or off, was on in<br />
previous PHP releases and is turned off by default now. This makes<br />
the situation for libraries and released software a lot harder<br />
which has to work with different configurations.<br />
Check your php.ini, look for &#8220;magic_quotes_gpc&#8221;. It<br />
should be set to Off, not On. (magic_quotes_gpc = Off)<br />
BlueShoes fixes this by checking magic_quotes_gpc, and if it is on,<br />
it goes and undo&#8217;es the changes in _REQUEST, _GET, _POST and _COOKIE<br />
see bs_undoMagicQuotes().<br />
Note that there is other software around that does the opposite.</p>
<p>o) Make sure your code runs error free even if warnings and notices are<br />
enabled.</p>
<p>o) Use the new superglobals (_GET, _POST etc), make sure your code works<br />
if register_globals turned off. And we highly recommend to set<br />
register_globals to off.</p>
<p>o) JavaScript classes are named like in php, for example<br />
&#8220;Bs_FormFieldSelect.class.js&#8221;. If it&#8217;s a lib then it goes like<br />
Bs_FormFieldSelect.lib.js. A lib is simply a collection of functions<br />
for a special task, so not oo-code.</p>
<p>o) If you change something in code someone else maintains (and/or you&#8217;re<br />
not in the @author of the class or the function) then add your comments<br />
along with the date and your name, example:<br />
someCode(); //i did this because of that. 2002/10/16 &#8211;yourname</p>
<p>o) Don&#8217;t add email addresses in plain text. Even the phpdoc comments in<br />
the code get indexed, and thus could be spidered by email crawlers.<br />
Please use &#8220;&#8221; which makes it a bit harder to parse.</p>
<p>o) Naming (Glossary)</p>
<p>ecg          ElectroCardioGram<br />
In the code base you&#8217;ll find many subdirectories with that<br />
name. There are php code files that test our code. we<br />
thought calling them just &#8216;test&#8217; would not give them the<br />
honor they deserve, and prolly someone would just delete<br />
them. The ecg tests show a sysadmin very fast what&#8217;s not<br />
working (anymore) on his system, for example after the<br />
installation or after a php upgrade or whatever.</p>
<p>whtml        wysiwyg html. It&#8217;s a mime type in blueshoes. It means that<br />
the block [part] may be edited using wysiwyg. So it&#8217;s not<br />
xml compliant. A synonym would be &#8220;crappy html&#8221;.</p>
<p>URL: (see Bs_Url.class.php and its methods)<br />
scheme://user:pass@host:port/path?query#fragment<br />
example: url https://bill:gates@order.blue-shoes.com:81/forms/<br />
form.php?lang=fr&amp;sid=456456#address<br />
scheme     = https<br />
host       = order.blue-shoes.com<br />
port       = 81<br />
user       = bill<br />
pass       = gates<br />
path       = /forms/form.php<br />
query      = lang=fr&amp;sid=456456<br />
fragment   = address<br />
domain     = blue-shoes.com<br />
directory  = /forms/<br />
file       = form.php</p>
<p>xpv stands for xPointer vector. Match always returns an array, so xp<br />
is always an array, maybe an empty one.</p>
<p>UID          Unified ID.</p>
<a href='http://twitter.com/share?url=http%3A%2F%2Fsamet.kilictas.com%2F%3Fp%3D62&count=vertical&related=&text=Coding%20Guidelines%20For%20Developers' class='twitter-share-button' data-text='Coding Guidelines For Developers' data-url='http://samet.kilictas.com/?p=62' data-counturl='http://samet.kilictas.com/coding-guidelines-for-developers/' data-count='vertical' data-via='sametkilictas'>Tweet</a>]]></content:encoded>
			<wfw:commentRss>http://samet.kilictas.com/coding-guidelines-for-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

