<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	
	>
<channel>
	<title>
	Comments on: 40+ Useful Php tips for beginners &#8211; Part 2	</title>
	<atom:link href="https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/</link>
	<description>News, Technology, Entertainment and more</description>
	<lastBuildDate>Thu, 29 Nov 2012 02:29:03 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>
	<item>
		<title>
		By: Prabha		</title>
		<link>https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65318</link>

		<dc:creator><![CDATA[Prabha]]></dc:creator>
		<pubDate>Thu, 29 Nov 2012 02:29:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1686#comment-65318</guid>

					<description><![CDATA[Can anyone help me how to use session as given in 17. Don&#039;t use the $_SESSION variable directly]]></description>
			<content:encoded><![CDATA[<p>Can anyone help me how to use session as given in 17. Don&#8217;t use the $_SESSION variable directly</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: blacksonic		</title>
		<link>https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65317</link>

		<dc:creator><![CDATA[blacksonic]]></dc:creator>
		<pubDate>Sat, 14 Apr 2012 17:11:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1686#comment-65317</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65314&quot;&gt;Silver Moon&lt;/a&gt;.

Php uses copy on write, so if u dont alter an an inputs value it wont consume more memory]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65314">Silver Moon</a>.</p>
<p>Php uses copy on write, so if u dont alter an an inputs value it wont consume more memory</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: EllisGL		</title>
		<link>https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65316</link>

		<dc:creator><![CDATA[EllisGL]]></dc:creator>
		<pubDate>Fri, 13 Apr 2012 14:32:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1686#comment-65316</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65313&quot;&gt;Silver Moon&lt;/a&gt;.

I personally think short tags are awful. And the support of  is something I frown at. Equals sign should be an assignment, so one could read this as &quot;Question mark equals something?!&quot;. Are we so lazy, that writing out  is too much for us to bear?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65313">Silver Moon</a>.</p>
<p>I personally think short tags are awful. And the support of  is something I frown at. Equals sign should be an assignment, so one could read this as &#8220;Question mark equals something?!&#8221;. Are we so lazy, that writing out  is too much for us to bear?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: EllisGL		</title>
		<link>https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65315</link>

		<dc:creator><![CDATA[EllisGL]]></dc:creator>
		<pubDate>Fri, 13 Apr 2012 14:27:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1686#comment-65315</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65310&quot;&gt;Silver Moon&lt;/a&gt;.

If the second database is on the same server, then that would work OK. But if not, there&#039;s where the problem lies. It&#039;s been an issue I&#039;ve hit several times.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65310">Silver Moon</a>.</p>
<p>If the second database is on the same server, then that would work OK. But if not, there&#8217;s where the problem lies. It&#8217;s been an issue I&#8217;ve hit several times.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Silver Moon		</title>
		<link>https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65314</link>

		<dc:creator><![CDATA[Silver Moon]]></dc:creator>
		<pubDate>Fri, 13 Apr 2012 12:26:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1686#comment-65314</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65312&quot;&gt;Sander Marechal&lt;/a&gt;.

Using references does save memory when assigning large variables/arrays.
I have added a test code in point #24 to show that.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65312">Sander Marechal</a>.</p>
<p>Using references does save memory when assigning large variables/arrays.<br />
I have added a test code in point #24 to show that.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Silver Moon		</title>
		<link>https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65313</link>

		<dc:creator><![CDATA[Silver Moon]]></dc:creator>
		<pubDate>Fri, 13 Apr 2012 12:00:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1686#comment-65313</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65311&quot;&gt;smassey&lt;/a&gt;.

I agree with your and EllisGL&#039;s views on unit testing with singletons. They are to be avoided for proper unit testing.

Short tags should be avoided because :

1. If short tags are disabled on a certain hosting , then the whole code will be echoed to screen.

Php 5.4 has enabled &quot;short echo tags&quot; &#060;?= by default , not &#034;short tags&#034; &#060;? . 
So if &#039;short_open_tag = Off&#039; in php 5.4 the code inside short tags will not run , just echo as plain text.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65311">smassey</a>.</p>
<p>I agree with your and EllisGL&#8217;s views on unit testing with singletons. They are to be avoided for proper unit testing.</p>
<p>Short tags should be avoided because :</p>
<p>1. If short tags are disabled on a certain hosting , then the whole code will be echoed to screen.</p>
<p>Php 5.4 has enabled &#8220;short echo tags&#8221; &lt;?= by default , not &quot;short tags&quot; &lt;? .<br />
So if &#039;short_open_tag = Off&#039; in php 5.4 the code inside short tags will not run , just echo as plain text.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sander Marechal		</title>
		<link>https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65312</link>

		<dc:creator><![CDATA[Sander Marechal]]></dc:creator>
		<pubDate>Thu, 12 Apr 2012 11:51:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1686#comment-65312</guid>

					<description><![CDATA[&#062; 24. Handle large arrays carefully

PHP uses copy-on-write internally. Using references does not save memory. Only use references you want to change the input variable of a function.]]></description>
			<content:encoded><![CDATA[<p>&gt; 24. Handle large arrays carefully</p>
<p>PHP uses copy-on-write internally. Using references does not save memory. Only use references you want to change the input variable of a function.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: smassey		</title>
		<link>https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65311</link>

		<dc:creator><![CDATA[smassey]]></dc:creator>
		<pubDate>Thu, 12 Apr 2012 11:49:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1686#comment-65311</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65310&quot;&gt;Silver Moon&lt;/a&gt;.

&quot;Testing , development and deployment are different scenarios. The database class can be configured to be non-singleton during testing and singleton when deployed. Its just a change of configuration.&quot;

Would that not defeat the entire purpose of unit testing, if you&#039;re going to deploy different implementations to production than what you actually test ??? Sorry, but I must agree with EllisGL, singletons are a no-go if you want proper/strict unit testing. There are many more elegant and testable ways to achieve the exact same behavior without touching static properties. (giving them a parent scope and &quot;lazy loading&quot; the connections for example).

Next I would like to know why you state &quot;Do not use short tags&quot;. Is there a reason for this ? As of 5.4 they&#039;re even enabled by default.

For the rest I really enjoyed this article, great job.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65310">Silver Moon</a>.</p>
<p>&#8220;Testing , development and deployment are different scenarios. The database class can be configured to be non-singleton during testing and singleton when deployed. Its just a change of configuration.&#8221;</p>
<p>Would that not defeat the entire purpose of unit testing, if you&#8217;re going to deploy different implementations to production than what you actually test ??? Sorry, but I must agree with EllisGL, singletons are a no-go if you want proper/strict unit testing. There are many more elegant and testable ways to achieve the exact same behavior without touching static properties. (giving them a parent scope and &#8220;lazy loading&#8221; the connections for example).</p>
<p>Next I would like to know why you state &#8220;Do not use short tags&#8221;. Is there a reason for this ? As of 5.4 they&#8217;re even enabled by default.</p>
<p>For the rest I really enjoyed this article, great job.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Silver Moon		</title>
		<link>https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65310</link>

		<dc:creator><![CDATA[Silver Moon]]></dc:creator>
		<pubDate>Thu, 12 Apr 2012 06:29:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1686#comment-65310</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65309&quot;&gt;EllisGL&lt;/a&gt;.

&quot;One being if you set it up wrong, you are tied to only one database through out your app.&quot;

- If needed then there should be multiple database connections , but as long as working with a single database there is no need. Its not a rule, just an approach, the use of which very much depends on the requirements. 

Moreover, its possible to work with multiple databases using a single connection :

INSERT INTO `database2`.`table_name` (.........

It will work even if your mysqli object is connected to `database1`

&quot;The second one is Unit Testing. Makes it damn near impossible to test it properly.&quot;

- Testing , development and deployment are different scenarios. The database class can be configured to be non-singleton during testing and singleton when deployed. Its just a change of configuration.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65309">EllisGL</a>.</p>
<p>&#8220;One being if you set it up wrong, you are tied to only one database through out your app.&#8221;</p>
<p>&#8211; If needed then there should be multiple database connections , but as long as working with a single database there is no need. Its not a rule, just an approach, the use of which very much depends on the requirements. </p>
<p>Moreover, its possible to work with multiple databases using a single connection :</p>
<p>INSERT INTO `database2`.`table_name` (&#8230;&#8230;&#8230;</p>
<p>It will work even if your mysqli object is connected to `database1`</p>
<p>&#8220;The second one is Unit Testing. Makes it damn near impossible to test it properly.&#8221;</p>
<p>&#8211; Testing , development and deployment are different scenarios. The database class can be configured to be non-singleton during testing and singleton when deployed. Its just a change of configuration.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: EllisGL		</title>
		<link>https://www.binarytides.com/40-techniques-to-enhance-your-php-code-part-2/comment-page-1/#comment-65309</link>

		<dc:creator><![CDATA[EllisGL]]></dc:creator>
		<pubDate>Mon, 09 Apr 2012 13:42:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1686#comment-65309</guid>

					<description><![CDATA[&quot;Use the singleton pattern for special cases like database connection.&quot;

I would avoid using singletons for a number of reasons. One being if you set it up wrong, you are tied to only one database through out your app. The second one is Unit Testing. Makes it damn near impossible to test it properly.]]></description>
			<content:encoded><![CDATA[<p>&#8220;Use the singleton pattern for special cases like database connection.&#8221;</p>
<p>I would avoid using singletons for a number of reasons. One being if you set it up wrong, you are tied to only one database through out your app. The second one is Unit Testing. Makes it damn near impossible to test it properly.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
