<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7644036371045590440</id><updated>2012-02-16T05:38:28.286-08:00</updated><category term='arguments'/><category term='documentation'/><category term='nest'/><category term='encoding'/><category term='rsync'/><category term='phpunit'/><category term='singleton'/><category term='multiple interfaces php5'/><category term='hash'/><category term='strategy'/><category term='creations'/><category term='selenium ide'/><category term='iteratoraggregate'/><category term='iteration'/><category term='test'/><category term='webserver'/><category term='conflicts'/><category term='inheritance'/><category term='svn2web'/><category term='array_key_exists'/><category term='svn to web'/><category term='rss'/><category term='isset'/><category term='eclipse'/><category term='syntax check'/><category term='xml'/><category term='abstract'/><category term='copy  reference'/><category term='foreach'/><category term='mysql'/><category term='scalability'/><category term='==='/><category term='overload'/><category term='arrays'/><category term='wakeup'/><category term='commit'/><category term='object'/><category term='information'/><category term='equality'/><category term='xmlwriter'/><category term='observer'/><category term='protected'/><category term='load balancing'/><category term='ArrayAccess'/><category term='innodb'/><category term='magic methods'/><category term='reference'/><category term='optimization'/><category term='final'/><category term='regular expressions'/><category term='late static bindings'/><category term='methods'/><category term='ubuntu'/><category term='testing'/><category term='serialize'/><category term='json'/><category term='svn'/><category term='subversion'/><category term='php5'/><category term='curiosity'/><category term='array_walk'/><category term='syncronize'/><category term='value'/><category term='operator'/><category term='reflection'/><category term='=='/><category term='proxy'/><category term='equal'/><category term='javascript'/><category term='public'/><category term='debugging'/><category term='dynamic'/><category term='decorator'/><category term='monit'/><category term='compare directories'/><category term='command'/><category term='form'/><category term='interface'/><category term='unlink'/><category term='sleep'/><category term='design pattern'/><category term='php4'/><category term='php tests'/><category term='class'/><category term='overloading'/><category term='access'/><category term='php conference'/><category term='fwrite'/><category term='svn to ftp'/><category term='scripts'/><category term='linux'/><category term='debug'/><category term='svn2ftp'/><category term='php 5.3'/><category term='feed'/><category term='unserialize'/><category term='variabile'/><category term='php'/><category term='ajax'/><category term='static'/><category term='fopen'/><category term='overridind'/><category term='revert'/><category term='mysql duplication'/><category term='sychro'/><category term='netbeans'/><category term='databases'/><category term='private'/><category term='properties'/><category term='jquery'/><category term='lamp references'/><category term='clone'/><category term='iterator'/><category term='namespace'/><category term='passing parameters'/><category term='adapter'/><category term='exception'/><category term='md5'/><category term='use'/><category term='boolean'/><category term='ftp'/><category term='password'/><category term='db'/><category term='factory design pattern'/><title type='text'>PHP and tips</title><subtitle type='html'>PHP / LAMP blog: code snippets and suggestions, mini tutorials, reviews and links</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>81</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-4332515124357582549</id><published>2010-05-13T15:31:00.000-07:00</published><updated>2010-05-13T15:32:40.871-07:00</updated><title type='text'>PHP bitwise operators</title><summary type='text'>Bitwise operator, class flags and constant with PHP</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/4332515124357582549/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/05/php-bitwise-operators.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4332515124357582549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4332515124357582549'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/05/php-bitwise-operators.html' title='PHP bitwise operators'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-3063517091468447707</id><published>2010-04-24T04:56:00.001-07:00</published><updated>2010-04-24T04:56:32.282-07:00</updated><title type='text'>zend cache</title><summary type='text'>zend cache overview</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/3063517091468447707/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/04/zend-cache.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3063517091468447707'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3063517091468447707'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/04/zend-cache.html' title='zend cache'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-8768809558471920897</id><published>2010-04-22T14:05:00.000-07:00</published><updated>2010-04-22T14:14:46.945-07:00</updated><title type='text'>Site moved</title><summary type='text'>I've decided to move my blog to another my domain (hosted by dreamhost), mainly because of the  time wasted to format the text in my posts (very poor editor) and impossibility of uploading files.Ufortunately it's not been possible to move the "google followers"  to the new site (google limitation), so I've had to make another widget. If you keep following this blog, please join the new site (box </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/8768809558471920897/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/04/site-moved.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8768809558471920897'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8768809558471920897'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/04/site-moved.html' title='Site moved'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-839934239578549207</id><published>2010-04-20T15:37:00.000-07:00</published><updated>2010-04-22T14:17:55.160-07:00</updated><title type='text'>Custom rules for zend standard rewrite router</title><summary type='text'>In this post, an overview of Zend routing [official doc] and how set custom rule for routing (tested on Zend v1.10).  Routing is basically how zend associate URLs tothe  controllers, actions and parameters of the application (similar to apache mod_rewrite but PHP based therefore much more powerful).  Default routing  As it is known, the default Zend routing uses the  following schema:  [</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/839934239578549207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/04/custom-rules-for-zend-standard-rewrite.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/839934239578549207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/839934239578549207'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/04/custom-rules-for-zend-standard-rewrite.html' title='Custom rules for zend standard rewrite router'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_MN8voSaLS2M/S84tb1sn3DI/AAAAAAAAGos/eb9weSiXCC4/s72-c/logo.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-6163387871667707268</id><published>2010-04-20T14:13:00.000-07:00</published><updated>2010-04-22T14:18:48.792-07:00</updated><title type='text'>Inside wordpress: notes about common variables and functions to add extra features</title><summary type='text'>I've recently used wordpress to make some simple web sites. Wordpress is a very fast solution when creating a blog or a site of which the requirements are just a subset of the wordpress features.What we can do with wordpress: fixed pages, site news (that are blog posts), simple search, multi-level page and news content management, WYSIWYG editor, changeable themes, lots of free themes already </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/6163387871667707268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/04/ive-recently-used-wordpress-to-make.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6163387871667707268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6163387871667707268'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/04/ive-recently-used-wordpress-to-make.html' title='Inside wordpress: notes about common variables and functions to add extra features'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_MN8voSaLS2M/S84au7ctz_I/AAAAAAAAGok/JXk1FhabkGM/s72-c/wordpress-icon.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-3487399187213361239</id><published>2010-04-15T14:05:00.000-07:00</published><updated>2010-04-18T05:22:24.839-07:00</updated><title type='text'>sessions vs cookies with load balancer</title><summary type='text'>It's a well known fact that HTTP is a stateless protocol and cookies are needed to keep the communication session.When dealing with sessions with PHP, we have two main solutions:- set manual cookiesOne approach is using directly the PHP functions  to set the cookies. When possible I don't use manual cookies(except than keeping an hash string for the user identity or keep the session after the </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/3487399187213361239/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/04/sessions-vs-cookies-with-load-balancer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3487399187213361239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3487399187213361239'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/04/sessions-vs-cookies-with-load-balancer.html' title='sessions vs cookies with load balancer'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-8978253460549013017</id><published>2010-02-28T11:02:00.000-08:00</published><updated>2010-02-28T12:35:58.620-08:00</updated><title type='text'>Singleton is bad !!</title><summary type='text'> An interesting suggestion emerged from some speakers (1 and 2) of the last PHP UK conf is: do not use the Singleton design pattern !!At the beginning it made me a little astonished as it's one of the most widely used design patterns, in addition ZF and lots of other projects use it. However, after a while I agreed the idea. Singleton actually had created some problems when I had to do some class</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/8978253460549013017/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/02/singleton-is-bad.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8978253460549013017'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8978253460549013017'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/02/singleton-is-bad.html' title='Singleton is bad !!'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MN8voSaLS2M/S4rR-8pGQbI/AAAAAAAAGoY/Gz931AZwF7s/s72-c/images.jpeg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-1754758045081392329</id><published>2010-02-28T04:31:00.000-08:00</published><updated>2010-03-04T01:16:53.837-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='php conference'/><title type='text'>PHP UK conference 2010 talks</title><summary type='text'>I attended the PHP UK conference 2010 on Friday.  Unfortunately the event took place in one day, so there were  three talks at each time slot in different rooms. I had to choice the most promising each time. It was a pity to have some very interesting ones at the same time (like AntiPHPatterns and RDBMS, or DB optimisation and the PHP 5.3). Fortunately, I've already found almost all the slides </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/1754758045081392329/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/02/php-uk-conference-2010-talks.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1754758045081392329'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1754758045081392329'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/02/php-uk-conference-2010-talks.html' title='PHP UK conference 2010 talks'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-667708305338235306</id><published>2010-02-27T10:09:00.000-08:00</published><updated>2010-02-28T05:14:05.918-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='php conference'/><title type='text'>PHP UK 2009 conference - talk slides</title><summary type='text'>I've just searched and found the slides of the online talks  made at the PHP conference 2009 that I couldn't attend.For some of them, a few-line-summary.The future's so bright, I gotta wear shades (keynote)  by Aral Balkannot found :(Clouds on the horizon? Get ready for Drizzle by David AxmarkslidesDrizzle, a light faster version of mysql: only UTF8, features as plugin, semplified protocol. BSD </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/667708305338235306/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/02/php-uk-2009-conference-talk-slides.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/667708305338235306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/667708305338235306'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/02/php-uk-2009-conference-talk-slides.html' title='PHP UK 2009 conference - talk slides'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MN8voSaLS2M/S4lmsc85ZWI/AAAAAAAAGoI/QVhYUO57REg/s72-c/ScreenShot028.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-7871645697146491454</id><published>2010-02-14T05:27:00.000-08:00</published><updated>2010-02-14T05:43:12.090-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ftp'/><title type='text'>Upload a tree of files and subdirectory to a remote FTP server</title><summary type='text'>I've recently been asked to move a site (1Gb of files) from a Italian hosting linux (no ssh) to the same cheap hosting but to another server windows (damn ! no ssh, no console commands from PHP, the only way to upload files is the old slow uncool FTP).Problem: I've got an extremely poor upload bandwith in my house in UK. So, I've used another hosting with SSH (dreamhost, in US) and:1)  got data </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/7871645697146491454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/02/upload-tree-of-files-and-subdirectory.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/7871645697146491454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/7871645697146491454'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/02/upload-tree-of-files-and-subdirectory.html' title='Upload a tree of files and subdirectory to a remote FTP server'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-8712938719799242730</id><published>2010-02-05T13:29:00.000-08:00</published><updated>2010-02-05T13:37:32.238-08:00</updated><title type='text'>practice tests for zend php 5 certfication</title><summary type='text'>I'm selling4 exam practice online test for "Zend PHP 5 Certification", GBP 10.descriptionhttp://shop.zend.com/eu/php-certification/zend-php-certification-online-practice-testing.htmlcontact me at elvisciotti [at] gmail (dot) com, payment through paypal</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/8712938719799242730/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/02/practice-tests-for-zend-php-5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8712938719799242730'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8712938719799242730'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/02/practice-tests-for-zend-php-5.html' title='practice tests for zend php 5 certfication'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-6186786230245458183</id><published>2010-02-04T14:59:00.000-08:00</published><updated>2010-02-04T16:03:31.317-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scalability'/><title type='text'>PHP and scalability</title><summary type='text'>As PHP is becoming a widely used web server technology, more and more developers are comparing PHP with other technologies like J2EE or .NET.It has been the butt of criticism as considered not scalable: totally wrong !A system is scalable when is able to keep the performances under an increased load,  mainly due to more users.  Speaking about scripting execution velocity (that is a constant in </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/6186786230245458183/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/02/php-and-scalability.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6186786230245458183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6186786230245458183'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/02/php-and-scalability.html' title='PHP and scalability'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_MN8voSaLS2M/S2tgN2gamYI/AAAAAAAAGnc/_JGtdKKkwaE/s72-c/ScreenShot005.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-4667866329589624894</id><published>2010-01-30T10:27:00.001-08:00</published><updated>2010-01-30T10:44:20.589-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='curiosity'/><title type='text'>Who reads this blog ?</title><summary type='text'>This is the map made by google analytics on this blog.It's rather foreseeable to see which are the countries more interested in a technical blog.I'm only surprised to see no visits from China and Norway, as well as same number of visitors from Spain and Ukraine and Romania.To obtain a better paid job I'm really thinking about moving to Madagascar :D</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/4667866329589624894/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/01/who-reads-this-blog.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4667866329589624894'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4667866329589624894'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/01/who-reads-this-blog.html' title='Who reads this blog ?'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_MN8voSaLS2M/S2R6jIts0pI/AAAAAAAAGm4/sYX-uHqfS7E/s72-c/ScreenShot001.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-4574492170342454453</id><published>2010-01-30T03:57:00.000-08:00</published><updated>2010-01-30T10:20:26.287-08:00</updated><title type='text'>PHP for file moving / managing</title><summary type='text'>PHP is a technology damned cool for web application but the language doesn't provide an advanced syntax as Python in itself. However, by writing readable and maintenable code (for instance by smartly separating features in function and classes), PHP is satisfying also to make file managing / system scripts, IMHO of course :)ExampleHere is a simple script I'm using to copy the latest mp3 files </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/4574492170342454453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/01/simple-script-to-update.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4574492170342454453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4574492170342454453'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/01/simple-script-to-update.html' title='PHP for file moving / managing'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-9139087588698312456</id><published>2010-01-26T04:31:00.000-08:00</published><updated>2010-01-26T05:00:21.005-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scripts'/><title type='text'>Simple PHP script to edit front end components</title><summary type='text'>I've recently built a very simple web site. The only dynamic requirement was having some parts of the front end editable (WYSIWYG) by an administration area (user and password). Basically, a very simple basic CMS for one user.SolutionA MySQL database is not needed, saving to files is much more appropriate for these requirements. Also SQLite is not necessary, as we just want to do only basic </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/9139087588698312456/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/01/simple-script-to-edit-front-end.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/9139087588698312456'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/9139087588698312456'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/01/simple-script-to-edit-front-end.html' title='Simple PHP script to edit front end components'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-9204166846057342849</id><published>2010-01-20T04:35:00.000-08:00</published><updated>2010-01-30T11:10:56.170-08:00</updated><title type='text'>My Zend Certification</title><summary type='text'>Just passed my ZCE PHP5!!90 tech questions, some of them answerable only by reading some books, some others by knowing the exact behaviour and arguments of PHP5 functions and settings (quite a lot of stuff to remember considering also XML, PDO, STD lib,streams and filters), some other only with work experience, some of them with a code/algorithm comprehension ability and deep OOP skills.It will </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/9204166846057342849/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/01/my-zend-certification.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/9204166846057342849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/9204166846057342849'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/01/my-zend-certification.html' title='My Zend Certification'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-1661875662195259658</id><published>2010-01-14T07:44:00.000-08:00</published><updated>2010-01-15T17:24:37.580-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='databases'/><title type='text'>PDO example</title><summary type='text'>try {$pdo = new PDO("mysql:host=127.0.0.1;dbname=dev;","root","" );#$pdo-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);$pdo-&gt;exec("DELETE FROM `User` WHERE id&lt;&gt;293968 ");#insert$insertedRows = $pdo-&gt;exec("INSERT INTO `User` (username, password) VALUES ('elvis','ciotti') ");$lastInsertId = $pdo-&gt;lastInsertId();echo "Inserted $insertedRows rows [id = $lastInsertId]\n";$pdo-&gt;exec("DELETE </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/1661875662195259658/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2010/01/pdo-example.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1661875662195259658'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1661875662195259658'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2010/01/pdo-example.html' title='PDO example'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-2586982177192347654</id><published>2009-12-19T14:34:00.000-08:00</published><updated>2010-01-14T16:23:57.342-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='arrays'/><title type='text'>PHP Arrays sort</title><summary type='text'>There are lots of PHP defined function to order arrays (the core of PHP, technically are hashmaps), ordering by value or keys, preserving key order or not, using an user-defined function, normal or reverse order, etc... Following, some clear example of the main ones, and some tips about how to remember themORDER BY VALUE     sort():  order by VALUE  (keys destroyed and renumberted starting from </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/2586982177192347654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/12/php-arrays-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2586982177192347654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2586982177192347654'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/12/php-arrays-sort.html' title='PHP Arrays sort'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-527479328793915814</id><published>2009-12-10T14:06:00.000-08:00</published><updated>2010-01-30T08:05:31.660-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='netbeans'/><title type='text'>Netbeans 6.8</title><summary type='text'>Netbeans 6.8 is now available !New features:Symfony support  (integrated prompt, syntax + help for command line code generator, shortucts) + YAML syntax supportbetter code completion, supporting PHP 5.3 features (namespaces)PHPUnit improvementsPHP application from remote serversSQL better auto completitionEmbedded Browser + Web Preview for HTML and CSS</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/527479328793915814/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/12/netbeans-58.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/527479328793915814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/527479328793915814'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/12/netbeans-58.html' title='Netbeans 6.8'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-6797126031771383526</id><published>2009-11-26T13:39:00.000-08:00</published><updated>2009-12-10T14:18:33.733-08:00</updated><title type='text'>Checking PHP script performance with Xdebug</title><summary type='text'>Xdebug [http://www.xdebug.org/] is a useful tool to debug PHP scripts. An interesting feature is the script profiling.  If the option is enabled, Xdebug will be able to trace and save information (time, details) about all the functions/methods called in the script (CLI or Apache).  The aim of the profiling is mainly recognizing bottlenecks or simply what parts of the code that are slow.  In order</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/6797126031771383526/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/11/checking-php-script-performances-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6797126031771383526'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6797126031771383526'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/11/checking-php-script-performances-with.html' title='Checking PHP script performance with Xdebug'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_MN8voSaLS2M/Sw72omA5pAI/AAAAAAAAGms/wRNLvO0WSjs/s72-c/ScreenShot074.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-7638081459079921783</id><published>2009-11-19T15:08:00.000-08:00</published><updated>2010-01-15T17:19:47.434-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>Profiling MySQL</title><summary type='text'>To analyze the db server usage in a complex PHP application, the first step is to profile the db server.There are  lots of tools to profile, but I think it's very easy to make a customized code to save the data really needed.The idea is save information about some queries in the production environment (about 1% of the queries is usually enough, depending on the traffic).MySQL profilingHoping </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/7638081459079921783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/11/profiling-mysql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/7638081459079921783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/7638081459079921783'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/11/profiling-mysql.html' title='Profiling MySQL'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-3392072441577354855</id><published>2009-11-19T14:49:00.001-08:00</published><updated>2010-01-30T08:09:57.629-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='debugging'/><title type='text'>Simple effective PHP debugging + backtracking</title><summary type='text'>During PHP debugging I often need to debug complex data. Is not always possibile to use Xdebug and the IDE debugging features with MVC frameworks, and also some arrays/object are too big and unhandy for FirePHP.A valid solution might be a traditional "print_r"/"var_dump" + "exit"Two problems:1) accidental commits to the staging/production environment.2) it takes time to understand where they are </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/3392072441577354855/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/11/debug-and-backtrace-our-applications.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3392072441577354855'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3392072441577354855'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/11/debug-and-backtrace-our-applications.html' title='Simple effective PHP debugging + backtracking'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-2211409939193886398</id><published>2009-11-19T14:46:00.000-08:00</published><updated>2009-11-19T15:08:22.462-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>MySQL dump importing</title><summary type='text'>Today I realized that "mysqlimport" is not working as expected on Wamp environment.A working way to import a sql/dump file is to use the "mysql" executable#localhostmysql --u root -p   --user=root --force [DBNAME] &lt; [FILE.SQL]</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/2211409939193886398/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/11/import-mysql-dump.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2211409939193886398'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2211409939193886398'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/11/import-mysql-dump.html' title='MySQL dump importing'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-8812850533590827054</id><published>2009-11-16T16:08:00.000-08:00</published><updated>2009-11-16T16:47:34.166-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='php 5.3'/><title type='text'>PHP 5.3</title><summary type='text'>I've just read this pdf from I.A.'s blog about PHP 5.3 performances.My comments:PerformancesWhat I really consider good is the performance increasing (5/10%) that include a smarter behaviour with require/inclusion, smaller binary size and better stack performance.Features- Namespaces are OK, but not really necessary. A good code can be written also without them.- I think the best feature is the </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/8812850533590827054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/11/php-53.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8812850533590827054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8812850533590827054'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/11/php-53.html' title='PHP 5.3'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-3571177911190271008</id><published>2009-11-03T15:58:00.000-08:00</published><updated>2009-11-03T16:11:01.506-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='optimization'/><title type='text'>How to optimize PHP applications</title><summary type='text'>There are lots of advices on the web about how to speed up PHP applications.The best reading I've found are written by Ilia Alshanetsky [blog]:PHP &amp; PERFORMANCE [pdf]By: Ilia AlshanetskyCommon Optimization Mistakes  [pdf]PHP Quebec 2009Enjoy !</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/3571177911190271008/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/11/how-to-ooptimize-php-applications.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3571177911190271008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3571177911190271008'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/11/how-to-ooptimize-php-applications.html' title='How to optimize PHP applications'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-1121635591940691579</id><published>2009-10-15T13:35:00.000-07:00</published><updated>2010-01-15T17:22:28.473-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><title type='text'>a Javascript function to manage function timeout</title><summary type='text'>Today I worked with form validations and AJAX requests associated with the event keyup in the input fields.Sometimes the validation requires an AJAX call (for instance to check if the typed text already exists in the DB). In order to avoid a request for each char typed, a good solution might be using set/clearTimeout.With the aim of doing only one function to manage all the timeouts of  the </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/1121635591940691579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/10/javascript-function-to-manage-timeout.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1121635591940691579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1121635591940691579'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/10/javascript-function-to-manage-timeout.html' title='a Javascript function to manage function timeout'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-1340353434158141328</id><published>2009-10-12T13:41:00.000-07:00</published><updated>2009-10-13T09:57:54.738-07:00</updated><title type='text'>printing the backtrace in a complex PHP application</title><summary type='text'>the PHP debug_backtrace [man] function is very useful to understand where a function/method is called.It prints the back trace of the code.Example: In the framework I'm currently using there are ORM classes to access the DB. So, it takes long to understand where the query is launched when needed. Solution: save in a global variable (or in a field of the class) the list of the queries launched and</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/1340353434158141328/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/10/printing-backtrace-in-complex-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1340353434158141328'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1340353434158141328'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/10/printing-backtrace-in-complex-php.html' title='printing the backtrace in a complex PHP application'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-6444145927370150791</id><published>2009-10-12T13:38:00.000-07:00</published><updated>2009-10-12T13:41:41.451-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='regular expressions'/><title type='text'>How to search complex source code using regular expressions</title><summary type='text'>Today I needed to search the source code that ware calling a function with a complex array of parametersURL::Make( 'site/store.inc.php', array( 'action'=&gt;'view','id'=&gt; [... STH...] ,'idTwo'=&gt; [... STH...]  ) );Considering this requirements:- there are lots of similar function (to exclude from the search) with an argument less or an argument more- there may are additional spaces in the line- some </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/6444145927370150791/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/10/how-to-search-complex-source-code-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6444145927370150791'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6444145927370150791'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/10/how-to-search-complex-source-code-using.html' title='How to search complex source code using regular expressions'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-2574902645201836843</id><published>2009-10-12T12:38:00.000-07:00</published><updated>2009-10-12T13:38:12.070-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='load balancing'/><title type='text'>An idea for DB server load balancing</title><summary type='text'>If the application has a heavy load of reading queries and there are no problems with the application requirements,a simple possible idea to balance the db server loading is to run the INSERT/UPDATE/ALTER queries in all the servers and run the SELECT queries in just one server (chosen randomly).Have a look at the 'loadBalancedQuery' function: if the query modifies the db it will be executed in </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/2574902645201836843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/10/idea-for-db-server-load-balancing.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2574902645201836843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2574902645201836843'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/10/idea-for-db-server-load-balancing.html' title='An idea for DB server load balancing'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-1349261696007037552</id><published>2009-10-11T05:33:00.000-07:00</published><updated>2009-10-12T13:56:49.872-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='encoding'/><title type='text'>UTF8 in LAMP applications: overview and how to solve the common issues</title><summary type='text'>The problemIn a LAMP application the text is frequently saved/retrieved from/to a database and files. We must consider all the different encoding (mapping characher-byte value): latin1 iso8859-1, latin9, UTF-8 (utf8) etc...Lots of applications use ISO8859 encoding and some PHP functions to convert the characters (htmlentities, htmlspecialchars etc...)The solutionConverting all the text from an </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/1349261696007037552/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/10/utf8-in-lamp-applications-overview-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1349261696007037552'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1349261696007037552'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/10/utf8-in-lamp-applications-overview-and.html' title='UTF8 in LAMP applications: overview and how to solve the common issues'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-8836277724546364736</id><published>2009-09-28T15:35:00.001-07:00</published><updated>2009-09-30T11:43:10.278-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql duplication'/><title type='text'>Mass rows copying (duplicating) with filed customization - MySQL</title><summary type='text'>Let's suppose we have a table with the following structure and data:# `table`id |    a   |    b   |    c   |---------------------------1  | "aaa" | "xxx" |  "ccc"2  | "aab" | "yyy" |  "ccc"3  | "aba" | "yyy" |  "ccc"4  | "abc" | "xxx" |  "ccc"5  | "dcz" | "xxx" |  "eee" Now, we want to copy some records (only some columns) to the same table AND change some of them with a fixed value.Requirements:</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/8836277724546364736/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/09/mass-rows-copying-duplicating-with.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8836277724546364736'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8836277724546364736'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/09/mass-rows-copying-duplicating-with.html' title='Mass rows copying (duplicating) with filed customization - MySQL'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-4750714911111108535</id><published>2009-09-15T09:38:00.000-07:00</published><updated>2009-10-10T19:36:07.321-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='syntax check'/><title type='text'>How to recursively check syntax of PHP files</title><summary type='text'>The executable of PHP supports the '-l' option, that checks the syntax instead of parsing the file.Using the command 'find', it's possibile to do a interesting operation: syntax checking of all the files recursively, to avoid parse errors in some script !!find ./ -type f -name \*.php -exec php -l {} \; ";the result will be a list of files, example:No syntax errors detected in ./codebase/</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/4750714911111108535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/09/how-to-recursively-check-syntax-of-php.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4750714911111108535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4750714911111108535'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/09/how-to-recursively-check-syntax-of-php.html' title='How to recursively check syntax of PHP files'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-4257845336865605589</id><published>2009-08-30T14:07:00.000-07:00</published><updated>2009-08-30T14:19:54.387-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='command'/><title type='text'>help of useful commands</title><summary type='text'>In this post, just a link of files contains help guide ([command] --help) for the most common unix shell commands.cpfindgrepgunzipgziphelplsmvpstarwget</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/4257845336865605589/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/08/help-of-useful-commands.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4257845336865605589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4257845336865605589'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/08/help-of-useful-commands.html' title='help of useful commands'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-6122315801853766070</id><published>2009-08-23T03:45:00.000-07:00</published><updated>2009-08-23T04:07:06.540-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='webserver'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='monit'/><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><title type='text'>Monitor linux web-servers with monit</title><summary type='text'>"monit is a utility for managing and monitoring processes, files, directories and devices on a Unix system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations. E.g. monit can start a process if it does not run, restart a process if it does not respond and stop a process if it uses to much resources. You may use monit to monitor files, </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/6122315801853766070/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/08/monitor-linux-web-servers-with-monit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6122315801853766070'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6122315801853766070'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/08/monitor-linux-web-servers-with-monit.html' title='Monitor linux web-servers with monit'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-4171877151350859589</id><published>2009-08-22T10:24:00.000-07:00</published><updated>2009-08-22T10:52:52.328-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='compare directories'/><category scheme='http://www.blogger.com/atom/ns#' term='sychro'/><title type='text'>Compare Files between two directories recursively - PHP script</title><summary type='text'>In this post I'll present my PHP class to show differences (file missing or different file date) between files in two directories (recursively).It's useful to compare two websites (Example, test and live versioning the same server)  and show the differences, much faster than a FTP synchronization, and customizable (size differences instead of time, PHP copy commands with backup etc...).Example of</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/4171877151350859589/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/08/compare-files-between-two-directories.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4171877151350859589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4171877151350859589'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/08/compare-files-between-two-directories.html' title='Compare Files between two directories recursively - PHP script'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MN8voSaLS2M/SpArL0Fcp-I/AAAAAAAAGkA/JxcrGYPz6w4/s72-c/ScreenShot017.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-1334398367721779687</id><published>2009-07-21T14:00:00.000-07:00</published><updated>2009-07-21T14:10:04.988-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='equal'/><category scheme='http://www.blogger.com/atom/ns#' term='boolean'/><category scheme='http://www.blogger.com/atom/ns#' term='isset'/><title type='text'>benchmark: boolean variables value check</title><summary type='text'>$a  = NULL;$t = microtime(true);for($i = 0; $i&lt;10000000; $i++) {        if  ($a) {} }print microtime(true)-$t."\n"; //2.84 sec$t = microtime(true);for($i = 0; $i&lt;10000000; $i++) {        if  ($a==true) {} }print microtime(true)-$t."\n"; //3.52sec$t = microtime(true);for($i = 0; $i&lt;10000000; $i++) {        if  ($a===true) {} }print microtime(true)-$t."\n"; //3.0 sec$t = microtime(true);for($i = 0;</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/1334398367721779687/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/07/benchmark-boolean-variables-value-check.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1334398367721779687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1334398367721779687'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/07/benchmark-boolean-variables-value-check.html' title='benchmark: boolean variables value check'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-3027400979988208027</id><published>2009-07-21T13:15:00.000-07:00</published><updated>2009-12-02T09:04:57.705-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='array_key_exists'/><category scheme='http://www.blogger.com/atom/ns#' term='isset'/><title type='text'>benchmark: array_key_exists vs isset</title><summary type='text'>When the aim is to check if the element exists in an array and has a value not null, better to use isset(array[index]), that is much faster  than array_key_exists(index, array).#PHP 5.3.0 command line - Amd turion 64 1.6 Ghz#create array$a  = array();for($i = 0; $i&lt;100000; $i++) {       $a[] = "$i asd a".($i*2)." sd";}#isset$t = microtime(true);for($i = 0; $i&lt;10000000; $i++) {    isset($a[$i]);}</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/3027400979988208027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/07/performance-arraykeyexists-vs-issetar.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3027400979988208027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3027400979988208027'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/07/performance-arraykeyexists-vs-issetar.html' title='benchmark: array_key_exists vs isset'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-7717794583176398189</id><published>2009-07-18T11:10:00.000-07:00</published><updated>2009-07-18T04:28:21.685-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><category scheme='http://www.blogger.com/atom/ns#' term='selenium ide'/><category scheme='http://www.blogger.com/atom/ns#' term='php tests'/><title type='text'>Functional testing for web applications: Selenium IDE for firefox</title><summary type='text'>In a previous post I wrote about PHP Unit testing.In software science, the levels above Unit testing are Integration, System and System integration testing.For a standard web application I suggest to use only Selenium [official site], a powerful complete framework , distributed with apache licence 2.0 (a free-software, GPL compatible).Selenium includes many components. In my opinion the most </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/7717794583176398189/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/07/functional-testing-for-web-applications.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/7717794583176398189'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/7717794583176398189'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/07/functional-testing-for-web-applications.html' title='Functional testing for web applications: Selenium IDE for firefox'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_MN8voSaLS2M/SmGw8nPdFNI/AAAAAAAAGjQ/00vi-0LW-sU/s72-c/selenium-ide.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-7745673260462136976</id><published>2009-07-09T11:21:00.000-07:00</published><updated>2010-04-22T14:19:49.718-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='conflicts'/><category scheme='http://www.blogger.com/atom/ns#' term='revert'/><category scheme='http://www.blogger.com/atom/ns#' term='commit'/><category scheme='http://www.blogger.com/atom/ns#' term='subversion'/><category scheme='http://www.blogger.com/atom/ns#' term='netbeans'/><category scheme='http://www.blogger.com/atom/ns#' term='svn'/><title type='text'>How to solve SVN conflicts. Netbeans SVN plugin tools</title><summary type='text'>SVN [official site] is the most powerful open source version control software at the moment.Introduction (for who doesn't know it at all)Basically, SVN is a server/client system. The server that contains the repository (source code of our application).The clients get the source code (CHECK OUT) or only the new files (UPDATE) from the server. The opposite operation is called COMMIT, and consists </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/7745673260462136976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/07/how-to-solve-svn-conflicts-netbeans-svn.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/7745673260462136976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/7745673260462136976'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/07/how-to-solve-svn-conflicts-netbeans-svn.html' title='How to solve SVN conflicts. Netbeans SVN plugin tools'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_MN8voSaLS2M/SlpZcL5-TfI/AAAAAAAAGjI/Rv6ONIdCuXc/s72-c/vc-concepts.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-3770090097005902503</id><published>2009-07-09T11:20:00.001-07:00</published><updated>2010-04-26T15:58:17.941-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='svn2ftp'/><category scheme='http://www.blogger.com/atom/ns#' term='syncronize'/><category scheme='http://www.blogger.com/atom/ns#' term='svn to web'/><category scheme='http://www.blogger.com/atom/ns#' term='svn2web'/><category scheme='http://www.blogger.com/atom/ns#' term='rsync'/><category scheme='http://www.blogger.com/atom/ns#' term='svn to ftp'/><title type='text'>SVN to FTP/web on Windows with svn client+winscp</title><summary type='text'>Post moved to the new blog: Svn to ftpHow to deploy a web application  and to quickly deploy future updates/patches from a SVN repository into a remote web server (only with ftp access and without possibility to setup svn client) ?Here are my suggested steps:export SVN (that is obtain the last repository without ".svn" directories)process the exported SVN (e.g. adding or deleting files before </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/3770090097005902503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/07/svn-to-ftpweb-on-windows-with-svn.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3770090097005902503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3770090097005902503'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/07/svn-to-ftpweb-on-windows-with-svn.html' title='SVN to FTP/web on Windows with svn client+winscp'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-1700657928177673127</id><published>2009-07-06T11:13:00.000-07:00</published><updated>2009-07-09T14:10:13.255-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='test'/><category scheme='http://www.blogger.com/atom/ns#' term='phpunit'/><title type='text'>Unit testing: a brief introduction to PHPUnit</title><summary type='text'>Every software needs testing [wiki], starting with testing software units [wiki] (the smallest parts of a software, that are functions and classes).Briefly, a test is a code which runs and ensure that our code behaves as expected. Here is an example of a test to check a mail validator function:print ( validateEmail("test@site.com") &amp;&amp; !validateEmail("test@site") &amp;&amp; !validateEmail("@site") &amp;&amp; ! </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/1700657928177673127/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/07/unit-testing-brief-introduction-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1700657928177673127'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1700657928177673127'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/07/unit-testing-brief-introduction-to.html' title='Unit testing: a brief introduction to PHPUnit'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_MN8voSaLS2M/SlJIs8A3owI/AAAAAAAAGi4/qTfrp7XmrpE/s72-c/phpunit-logo.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-8781997816111832542</id><published>2009-07-01T13:58:00.000-07:00</published><updated>2009-07-06T12:09:57.356-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='php 5.3'/><title type='text'>PHP 5.3.0 released</title><summary type='text'>I don't like writing posts for every new PHP release as other PHP blogs, but this time it's worth doing it !PHP 5.3 implements important new OOP features:namespaceslate static binding and __callStatic() !anonymous functionsPhar extension (pratically, it's the same as JAR for java files)Forother improvments and bug fixing, see change log</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/8781997816111832542/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/07/php-530-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8781997816111832542'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8781997816111832542'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/07/php-530-released.html' title='PHP 5.3.0 released'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-8528886417840634729</id><published>2009-06-27T04:50:00.000-07:00</published><updated>2009-06-30T14:54:39.077-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='eclipse'/><category scheme='http://www.blogger.com/atom/ns#' term='debug'/><category scheme='http://www.blogger.com/atom/ns#' term='netbeans'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>Debugging techniques with free tools [updated 30 June]</title><summary type='text'>Netbeans PHP 6.* + Xdebug + Firefox (with netbeans extension to server debug with javascript) !howto configure with Wamp 2.0h:- download php_xdebug-2.0.4-5.2.8.dll into the Wamp folder- open port 9000 in the firewall- edit php.ini adding[xdebug]zend_extension_ts="c:/wamp/bin/php/php5.2.9-2/ext/php_xdebug-2.0.4-5.2.8.dll"xdebug.remote_enable=onxdebug.remote_handler=dbgpxdebug.remote_host=</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/8528886417840634729/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/debugging-techniques-draft.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8528886417840634729'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8528886417840634729'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/debugging-techniques-draft.html' title='Debugging techniques with free tools [updated 30 June]'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_MN8voSaLS2M/Skf4zmkTy4I/AAAAAAAAGiw/yCs7w2K2laA/s72-c/ScreenShot008.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-6631958210250986973</id><published>2009-06-23T04:38:00.000-07:00</published><updated>2009-06-23T08:46:31.481-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='password'/><category scheme='http://www.blogger.com/atom/ns#' term='hash'/><category scheme='http://www.blogger.com/atom/ns#' term='form'/><category scheme='http://www.blogger.com/atom/ns#' term='md5'/><title type='text'>Symfony: password hashing and login</title><summary type='text'>It's a good practice not to keep the clear values of the passwords in the db, but to store only their hash values.You can do login operations comparing the hash value of the inserted password with the stored hash value.How to do it with Symfony 1.2, propel ORM, MD5 hashing:db schema: Use a VARCHAR, length must be at least 32 validator:- require a minimum length (ex: 3 chars) or (better) regexp </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/6631958210250986973/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/symfony-maintain-chipered-stored.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6631958210250986973'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6631958210250986973'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/symfony-maintain-chipered-stored.html' title='Symfony: password hashing and login'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-8641544656533859646</id><published>2009-06-22T11:34:00.000-07:00</published><updated>2009-06-22T12:25:50.540-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lamp references'/><title type='text'>LAMP documentation links</title><summary type='text'>PHPOnline http://www.php.net/manual/en/Offline CHM http://uk2.php.net/get/php_manual_en.chm/from/a/mirrorpear packages http://pear.php.net/manual/en/packages.phpSYMFONY v1.2book (the definitive guide) : online html |  PDF versionJobeet tutorial - propel: online html | PDF versionForms: online html | PDF versionCookbook:  online html |  PDF versionAPI online http://www.symfony-project.org/api/1_2/</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/8641544656533859646/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/lamp-documentation-links.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8641544656533859646'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8641544656533859646'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/lamp-documentation-links.html' title='LAMP documentation links'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-7878604638815972139</id><published>2009-06-14T14:52:00.000-07:00</published><updated>2009-06-23T05:25:41.828-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jquery'/><category scheme='http://www.blogger.com/atom/ns#' term='ajax'/><category scheme='http://www.blogger.com/atom/ns#' term='json'/><title type='text'>JSON generation with PHP and parsing with jQuery</title><summary type='text'>JSON [official site][wiki] is a data interchange format (similar to XML, but simpler), often used for WEB 2.0 applications to load structured data with AJAX HTTP calls.- PHP offers functions to encode and decode JSON from/to a PHP value.- jQuery includes a function (getJSON) to parse HTTP resource with JSON data.JSON pseudo grammar#json block: comma separated couple key: valueJSON_BLOCK = { KEY1:</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/7878604638815972139/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/json-generation-with-php-and-parsing.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/7878604638815972139'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/7878604638815972139'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/json-generation-with-php-and-parsing.html' title='JSON generation with PHP and parsing with jQuery'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-7866785406309639779</id><published>2009-06-10T01:41:00.000-07:00</published><updated>2009-06-10T02:11:07.569-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>MySQL : version differences notes (draft)</title><summary type='text'>Relevant features added in Mysql 4.0FULLTEXT searchINNODB tables (and on [delete|update features]UNION statementTRUNCATE TABLE statementmultiple table delete and updateRelevant features added in Mysql 4.1Subquery (nested query) supported"CREATE table LIKE table 2" syntax supportedadded storages:- EXAMPLE (for developers)- NBCLUSTER (table partitioned over many computers)- CSV (comma separated </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/7866785406309639779/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/mysql-version-differences-notes-draft.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/7866785406309639779'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/7866785406309639779'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/mysql-version-differences-notes-draft.html' title='MySQL : version differences notes (draft)'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-4685254838892199206</id><published>2009-06-08T12:25:00.000-07:00</published><updated>2009-06-08T12:55:28.451-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='innodb'/><title type='text'>INNODB storage engine: notes</title><summary type='text'>Advantagestransactionsrow-level lockingforeign key constraints ! and behaviourON [DELETE|UPDATE] [RESTRICT|CASCADE|SET NULL|NO ACTION|SET DEFAULT]DisadvantagesINNODB does NOT support FULLTEXT index (MyISAM does)not initial value for auto_increment keys</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/4685254838892199206/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/innodb-storage-engine-notes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4685254838892199206'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4685254838892199206'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/innodb-storage-engine-notes.html' title='INNODB storage engine: notes'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-4797846381101634598</id><published>2009-06-08T09:20:00.000-07:00</published><updated>2009-06-08T09:24:32.152-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='array_walk'/><title type='text'>array_walk example</title><summary type='text'>bool array_walk ( array &amp;$array  , callback  $funcname [, mixed $userdata ] )/*  example !! *  transform array with other arrays as elements into an array with simple elements * array trasform ! */$ar = array( array(1,2), array(10,20), array(100,200) );function sum(&amp;$ar) //NOTE: Argument By reference{    $ar = $ar[0]+$ar[1];}array_walk($ar, "sum");print_r($ar);/*Array(    [0] =&gt; 3    [1] =&gt; 30</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/4797846381101634598/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/arraywalk-example.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4797846381101634598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4797846381101634598'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/arraywalk-example.html' title='array_walk example'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-3841888260546154912</id><published>2009-06-08T06:07:00.000-07:00</published><updated>2009-06-09T02:02:51.131-07:00</updated><title type='text'>PHP security: input validation and XSS</title><summary type='text'>for lots of reasons,  security included, it's very important to validate all user input and protect our application from intentional or accidental wrong inputs.First of all, here are some advicesdon't use register_globals ! A malicious user may change value of script variables simply modifying the query stringdon't use $_REQUEST: possibile loss of data. Use $_GET and $_POSTNumber validationuse </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/3841888260546154912/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/php-security-input-validation-xss.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3841888260546154912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3841888260546154912'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/php-security-input-validation-xss.html' title='PHP security: input validation and XSS'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-4674022532700070980</id><published>2009-06-08T03:11:00.000-07:00</published><updated>2010-01-16T03:07:46.140-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='strategy'/><category scheme='http://www.blogger.com/atom/ns#' term='design pattern'/><title type='text'>Design Pattern: Strategy</title><summary type='text'>Strategy is a way to encapsulate, manage and interchange (also at runtime) algorithms.In the following example, we have three classes (A,B and C) that implement an interface with the method f().The class AlgoContainer must be initiated by passing the object (external instantiation) or the class name (internal instantation).Interface StrategyInt{  public function f();}class A implements </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/4674022532700070980/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-strategy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4674022532700070980'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4674022532700070980'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-strategy.html' title='Design Pattern: Strategy'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-4343795721984350046</id><published>2009-06-08T02:48:00.000-07:00</published><updated>2010-01-16T03:16:46.352-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='design pattern'/><category scheme='http://www.blogger.com/atom/ns#' term='decorator'/><title type='text'>Design Pattern: Decorator</title><summary type='text'>Decorator is similar to Proxy.Basically, decorator is an extension (or wrapper) of the original class (component) and adds features.A decorator contains a pointer to the component class (initialized by the  constructor), and the methods of the component overridden.Example:class ImgComponent {private $src;private $alt;public function __construct($name, $src) { /* assign to properties*/ };public </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/4343795721984350046/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-decorator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4343795721984350046'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4343795721984350046'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-decorator.html' title='Design Pattern: Decorator'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-5359204351741321202</id><published>2009-06-08T01:56:00.000-07:00</published><updated>2010-01-16T03:18:48.479-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='adapter'/><category scheme='http://www.blogger.com/atom/ns#' term='design pattern'/><title type='text'>Design Pattern: Adapter</title><summary type='text'>The Adapter design pattern is basically a wrapper, that is a class which provides methods to access to another class.It's commonly used to normalize incompatibile interfaces.It's similar to Proxy pattern, but it's a little different. Proxy includes an object and controls accesses to it; Adapter provides an interface to the object, usually by inheritance.class A {public static function sort(array </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/5359204351741321202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-adapter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/5359204351741321202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/5359204351741321202'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-adapter.html' title='Design Pattern: Adapter'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-33857954001628980</id><published>2009-06-07T13:44:00.000-07:00</published><updated>2010-01-16T03:19:46.350-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='observer'/><title type='text'>Design Pattern: Observer</title><summary type='text'>The behavioural design pattern Observer allows to automatically update one-to-many dependences.Structure: an object (Hence: $subject) contains a list of observer references, and provides a method notify() that invoke update() of every observer. Also observers have a reference to $subject, used inside update().Commonly used to event handling (listeners) and login issues.Implementation in PHP5:</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/33857954001628980/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-observer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/33857954001628980'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/33857954001628980'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-observer.html' title='Design Pattern: Observer'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-2711145225523544063</id><published>2009-06-07T13:17:00.000-07:00</published><updated>2009-06-07T13:42:07.162-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='design pattern'/><category scheme='http://www.blogger.com/atom/ns#' term='proxy'/><title type='text'>Design Pattern: Proxy</title><summary type='text'>It provides a filtered controlled access to an object, without exposing it directly.How to implement in PHP5:Declare a class:constructor: instantiates the object (only the first time) and keeps the instance into a private properties- implement the methods that provide a controlled access to the internal objector- use the magic method __call($name, $value), then checks/filters the name and </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/2711145225523544063/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-proxy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2711145225523544063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2711145225523544063'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-proxy.html' title='Design Pattern: Proxy'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-3854687587913465853</id><published>2009-06-07T12:32:00.000-07:00</published><updated>2010-01-16T02:51:46.511-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='factory design pattern'/><title type='text'>Design Pattern: Factory</title><summary type='text'>Factory is a creational design pattern which handles object creation.A factory class provides the methods to create object (whit a superclass in common), but let subclasses to decide which class will be instantiated.Basically, it contains a static method ("connect" in the example below) that accept one parameter and makes a switch on it. Depending on the parameter, a new object of different type </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/3854687587913465853/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-factory.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3854687587913465853'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3854687587913465853'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-factory.html' title='Design Pattern: Factory'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-4255658911067641718</id><published>2009-06-07T07:51:00.000-07:00</published><updated>2009-06-09T02:09:15.119-07:00</updated><title type='text'>Design Pattern: Value</title><summary type='text'>Consider a class Val which contains a value, and a method add() which add another value with the same type.class Val {   private $value;   public function __construct($value=0) {$this-&gt;value = $value;  }   public function    get() { return $this-&gt;value; }   public function add($newVal) {        //(1) WRONG:       //$this-&gt;addV += $value; //WRONG !!       // (2) RIGHT !!              return new </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/4255658911067641718/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-value.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4255658911067641718'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4255658911067641718'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-value.html' title='Design Pattern: Value'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-2477925377898265909</id><published>2009-06-07T07:27:00.000-07:00</published><updated>2009-06-07T07:51:00.563-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='singleton'/><title type='text'>Design Pattern Singleton</title><summary type='text'>Singleton is a creational pattern which ensures a class has only one instance, and provide a global pointer to access it.The most common example is a database connection.The idea: the class doesn't provide a constructor, but a method to return an instance. That instance is assigned to a static properties and is instantiated only at the 1st access.class Example{    // Hold an instance of the class</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/2477925377898265909/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-singleton.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2477925377898265909'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2477925377898265909'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/design-pattern-singleton.html' title='Design Pattern Singleton'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-2954191589187963458</id><published>2009-06-07T05:47:00.000-07:00</published><updated>2009-06-07T06:35:05.158-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='xmlwriter'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><category scheme='http://www.blogger.com/atom/ns#' term='feed'/><category scheme='http://www.blogger.com/atom/ns#' term='rss'/><title type='text'>XMLWriter</title><summary type='text'>the PHP5 XMLWriter  class allows to easily create XML well-formed documents.The most useful methods:openURI($output) // use 'php://output' as argument to stream directlystartDocument('1.0') // add the  initial tag. 1st argument : xml versionwriteElement('hr') // write the empty node [hr/]writeAttribute('src','img.gif') //write the attribute (inside the last node) and valuee.g: [img src="http://</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/2954191589187963458/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/xmlwriter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2954191589187963458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2954191589187963458'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/xmlwriter.html' title='XMLWriter'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MN8voSaLS2M/SivBy2rhoYI/AAAAAAAAGcs/SrV9iLkPAKw/s72-c/ScreenShot001.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-4549008920559502746</id><published>2009-06-07T05:14:00.000-07:00</published><updated>2009-06-07T05:30:07.860-07:00</updated><title type='text'>SPL: DirectoryIterator</title><summary type='text'>foreach (new DirectoryIterator('.') as $fileInfo) {    //if($fileInfo-&gt;isDot()) continue;    echo "Name: ".$fileInfo-&gt;getFilename() . "\n";    echo "Last : ".date("d/m/Y H:i", $fileInfo-&gt;getCTime()) . "\n";    echo "Size: ".$fileInfo-&gt;getSize() . " byte\n";    echo "Type: ".$fileInfo-&gt;getType() . "\n"; //dir or file    echo "Executable: ".($fileInfo-&gt;isExecutable()?"yes":"no") . "\n";    echo "</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/4549008920559502746/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/spl-directoryiterator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4549008920559502746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4549008920559502746'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/spl-directoryiterator.html' title='SPL: DirectoryIterator'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-6239639128365204266</id><published>2009-06-06T09:59:00.000-07:00</published><updated>2009-06-21T10:50:22.083-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='unlink'/><category scheme='http://www.blogger.com/atom/ns#' term='fopen'/><category scheme='http://www.blogger.com/atom/ns#' term='ArrayAccess'/><category scheme='http://www.blogger.com/atom/ns#' term='fwrite'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><title type='text'>ArrayAccess: use object as an array, file manager example</title><summary type='text'>ArrayAccess (PHP5) allows to treat objects as an array.View below the interface scheme, with explanatory commentsArrayAccess { //PHP5 built-in Interface// returns true/false if the element in the position $offset exists/doesn't existabstract public boolean offsetExists ( string $offset ) // returns the element at the position $offsetabstract public mixed offsetGet ( string $offset )// set the </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/6239639128365204266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/arrayaccess-use-objects-as-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6239639128365204266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6239639128365204266'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/arrayaccess-use-objects-as-array.html' title='ArrayAccess: use object as an array, file manager example'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-5955687895733393060</id><published>2009-06-06T08:18:00.000-07:00</published><updated>2009-06-06T08:33:18.338-07:00</updated><title type='text'>References are not pointer in PHP5 !</title><summary type='text'>function foo(&amp;$var){    $var = 2;}$i = 1;foo($i);print $i; //prints "2"but :function foo(&amp;$var){    $i = 2;    $var = &amp;$i;    print $var; //prints "2"}$i=1;foo($i);print $i; //prints "1" !!!Returning reference from functions:function &amp;foo(&amp;$var){    $i = 2;    $var = &amp;$i;    return $var;}$i=1;print foo($i); // prints "2"</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/5955687895733393060/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/references-are-not-pointer-in-php5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/5955687895733393060'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/5955687895733393060'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/references-are-not-pointer-in-php5.html' title='References are not pointer in PHP5 !'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-6499738099594611445</id><published>2009-06-06T07:08:00.000-07:00</published><updated>2009-06-07T05:36:38.898-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='exception'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><category scheme='http://www.blogger.com/atom/ns#' term='nest'/><title type='text'>Exceptions in PHP5</title><summary type='text'>PHP5 supports Exception model, like C++/C# and Java.syntax to catch exception:try {//code which can launch an exception// [...]// manual exception throwthrow new Exception("thrown exception");//not executed ! (throw command is caught belowprint "not printed!";}catch(Exception $e) { print $e-&gt;getMessage();}this code prints : "thrown exception".It's possibile to throw an exception inside a catch </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/6499738099594611445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/exceptions-in-php5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6499738099594611445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6499738099594611445'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/exceptions-in-php5.html' title='Exceptions in PHP5'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-8360104565086602397</id><published>2009-06-06T05:00:00.000-07:00</published><updated>2009-06-06T07:07:04.206-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='use'/><category scheme='http://www.blogger.com/atom/ns#' term='namespace'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><title type='text'>PHP5 Namespaces</title><summary type='text'>Namespaces are available in PHP as of PHP 5.3.0A namespace is a container with classes, function and constants (also available in PHP&gt;5.3.0), similar to the namespaces in C++/C# and packages in Java. As indicated in the official PHP documentation, namespaces help us to solve name collisions and use alias to call long name classes/functions.definition syntax:&lt;?// no code or html allowed here ! ( </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/8360104565086602397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/php5-namespaces.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8360104565086602397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8360104565086602397'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/php5-namespaces.html' title='PHP5 Namespaces'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-8684375577862861252</id><published>2009-06-06T03:25:00.000-07:00</published><updated>2009-06-21T10:46:28.626-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='late static bindings'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><title type='text'>Late static Bindings (PHP &gt;= 5.3.0)</title><summary type='text'>in programming languages, binding is the association of the values with the  identifiers.association before running: early bindingassociation at runtime: late binding (also called virtual or dynamic)PHP5 supports the classic late binding. At runtime, PHP5 distinguishes the superclass from the subclasses object, respecting the overridden methods rules.The late binding for static methods are </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/8684375577862861252/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/late-bindings-and-late-static-bindings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8684375577862861252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8684375577862861252'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/late-bindings-and-late-static-bindings.html' title='Late static Bindings (PHP &gt;= 5.3.0)'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-2052795295875739818</id><published>2009-06-05T17:24:00.000-07:00</published><updated>2009-06-07T05:37:21.825-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='object'/><category scheme='http://www.blogger.com/atom/ns#' term='reference'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><title type='text'>Object references, assignment and as function arguments</title><summary type='text'>As of PHP5, objects are treated REFERENCE ! (same behaviour as C++ and Java)1) assignment from an objects to another copies the reference, not the content !!What is a reference ? it's a variabile/object  that ONLY  contains the pointer to the effective object in the memory. As I said in a previous post, the assigment instruction copy ONLY the value (pointer) of the object-pointer, it doesn't </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/2052795295875739818/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/object-reference-objects-as-arguments.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2052795295875739818'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2052795295875739818'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/object-reference-objects-as-arguments.html' title='Object references, assignment and as function arguments'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-1803704287821062812</id><published>2009-06-05T13:13:00.000-07:00</published><updated>2009-06-05T13:44:29.248-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='reflection'/><category scheme='http://www.blogger.com/atom/ns#' term='documentation'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><category scheme='http://www.blogger.com/atom/ns#' term='information'/><title type='text'>Obtain information about a class</title><summary type='text'>PHP5 includes interesting APIs to obtain information (list of members and methods) about the internal classes or interfaces.Example of PHP5 interesting classes/interfaces: Exception, Iterator.To obtain information about a class, instantiate the class ReflectionClass passing the name of the class we want information about. Now pass that instance to the static method export() of the class </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/1803704287821062812/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/obtain-information-about-class.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1803704287821062812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/1803704287821062812'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/obtain-information-about-class.html' title='Obtain information about a class'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-9193993537692014172</id><published>2009-06-05T09:03:00.000-07:00</published><updated>2009-06-21T10:20:06.603-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='operator'/><category scheme='http://www.blogger.com/atom/ns#' term='equal'/><category scheme='http://www.blogger.com/atom/ns#' term='=='/><category scheme='http://www.blogger.com/atom/ns#' term='object'/><category scheme='http://www.blogger.com/atom/ns#' term='variabile'/><category scheme='http://www.blogger.com/atom/ns#' term='==='/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><category scheme='http://www.blogger.com/atom/ns#' term='equality'/><title type='text'>the "==" and the "===" operators</title><summary type='text'>PHP has two types of comparison operators: "==" and "===" ( and respectively "!=" and "!==" ).Variables"==" offers a simple comparison of the content of variables, skipping the type (int, string, boolean,...) of the variables.The following expression are equivalent to the operator "==":false 0 "" '' "0" 0.0 -0 !1 array() $i // where $i is not initialized (notice generated) strpos("abcd","a") // (</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/9193993537692014172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/and-operators.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/9193993537692014172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/9193993537692014172'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/and-operators.html' title='the &quot;==&quot; and the &quot;===&quot; operators'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-9191135779351811510</id><published>2009-06-05T07:51:00.000-07:00</published><updated>2009-06-21T10:03:51.956-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='final'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><title type='text'>final keyword in PHP5</title><summary type='text'>Likewise Java, the meaning of the keyword "final" in php5 is:final classes: not extendablefinal class A { ...} final methods: not overridableclass A { final public function f() { ... } ...} final class members(properties): not supported in PHP5 !! (differently from Java)</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/9191135779351811510/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/final-keyword-in-php5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/9191135779351811510'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/9191135779351811510'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/final-keyword-in-php5.html' title='final keyword in PHP5'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-5152430864347486933</id><published>2009-06-05T02:44:00.000-07:00</published><updated>2009-06-07T05:39:28.578-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='serialize'/><category scheme='http://www.blogger.com/atom/ns#' term='unserialize'/><category scheme='http://www.blogger.com/atom/ns#' term='sleep'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><category scheme='http://www.blogger.com/atom/ns#' term='wakeup'/><title type='text'>serialize, unserialize, __sleep() and wakeup()</title><summary type='text'>definitions:Serialization: convert an object into a string (storable representation). The included object (instantiated and assigned to internal members) are included in the string.Unserialization: convert the string into the original objectPossibile uses: shopping cart serialize (to use after or to save into a db), user session save, object transfer between different applications.serialize($</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/5152430864347486933/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/serialize-unserialize-sleep-and-wakeup.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/5152430864347486933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/5152430864347486933'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/serialize-unserialize-sleep-and-wakeup.html' title='serialize, unserialize, __sleep() and wakeup()'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-6054879828420822017</id><published>2009-06-05T01:36:00.000-07:00</published><updated>2009-06-21T10:01:14.054-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='foreach'/><category scheme='http://www.blogger.com/atom/ns#' term='object'/><category scheme='http://www.blogger.com/atom/ns#' term='iterator'/><category scheme='http://www.blogger.com/atom/ns#' term='iteration'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><category scheme='http://www.blogger.com/atom/ns#' term='iteratoraggregate'/><title type='text'>Object iteration 2/2</title><summary type='text'>about object iteration, in php5 it's possibile to use Iterators (similar to Java and C++).Iterator is a PHP5 default interface that includes the public methods (to implement):mixed current ( )  // returns the current element in the loop ($key)scalar key ( )         // returns the current key in the loop   ($val)void next ( )          // called for obtain the next elementvoid rewind ( )     // </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/6054879828420822017/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/object-iteration-22.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6054879828420822017'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/6054879828420822017'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/object-iteration-22.html' title='Object iteration 2/2'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-7136169468525080296</id><published>2009-06-05T01:21:00.000-07:00</published><updated>2009-06-21T09:58:27.735-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='foreach'/><category scheme='http://www.blogger.com/atom/ns#' term='object'/><category scheme='http://www.blogger.com/atom/ns#' term='iteration'/><category scheme='http://www.blogger.com/atom/ns#' term='interface'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><title type='text'>Object iteration 1/2</title><summary type='text'>the construct foreach in PHP5 supports  also object, in addition to arrays.foreach($object as $key=&gt;$val){//$key will be equal to the nth member name//$val will be equal to the nth member value}Which members are visibile ? it depends on the "foreach" position !inside the class ($this is the object): all the members are visibileoutside the class: only public members are visibleinside an inherited </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/7136169468525080296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/object-iteration-12.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/7136169468525080296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/7136169468525080296'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/object-iteration-12.html' title='Object iteration 1/2'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-2886999604939768929</id><published>2009-06-04T11:29:00.000-07:00</published><updated>2009-06-21T09:51:56.608-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='overload'/><category scheme='http://www.blogger.com/atom/ns#' term='dynamic'/><category scheme='http://www.blogger.com/atom/ns#' term='overloading'/><category scheme='http://www.blogger.com/atom/ns#' term='magic methods'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><category scheme='http://www.blogger.com/atom/ns#' term='creations'/><title type='text'>"Overloading" in PHP5 and magic methods</title><summary type='text'>PHP doesn't support constructor / methods overloading with the classical syntax !"Overloading" in PHP5 is realized via the magic method __call($functionName, $argumentsArray)Dynamic creation of PROPERTIESLet's consider a class X (without content) and one its instanceclass X {}$x = new X();Now, If we try to read the inexistent property "m1" of the class, that is:print $-&gt;m1;we haveif the class X </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/2886999604939768929/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/overloading-in-php5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2886999604939768929'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2886999604939768929'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/overloading-in-php5.html' title='&quot;Overloading&quot; in PHP5 and magic methods'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-3371675953516008493</id><published>2009-06-04T10:58:00.000-07:00</published><updated>2009-06-07T05:42:03.028-07:00</updated><title type='text'>polymorphism in PHP5</title><summary type='text'>polymorphism in PHP5 sample class superclass{    public function f() { print "superclass-method\n"; }}class subclass extends superclass{    //override    public function f() { print "subclass-method\n"; }    public function added() { print "subclass-added-method\n"; }}function callF( $obj) //superclass{    $obj-&gt;f();    if ($obj instanceof subclass) $obj-&gt;added();}callf(new superclass()); //</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/3371675953516008493/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/polymorphism-in-php5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3371675953516008493'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3371675953516008493'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/polymorphism-in-php5.html' title='polymorphism in PHP5'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-8111212378367799600</id><published>2009-06-04T10:00:00.000-07:00</published><updated>2009-06-21T09:35:24.462-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='multiple interfaces php5'/><title type='text'>Implementing multiple interfaces in PHP5 and instanceof operator</title><summary type='text'>//interfacesinterface Intf{public function f(); }interface Intg{public function g();//public function f(); // error in case of multiple implementing (with Intf) }//simple implementationclass Cf implements Intf{public function f(){ print "interface Cf, function f"; } }//multiple implementationclass Cfg implements Intf, Intg{public function f(){ print "interface Cfg, function f"; }public function g</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/8111212378367799600/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/implementing-multiple-interfaces-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8111212378367799600'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8111212378367799600'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/implementing-multiple-interfaces-in.html' title='Implementing multiple interfaces in PHP5 and instanceof operator'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-3344533851319398218</id><published>2009-06-04T08:45:00.000-07:00</published><updated>2009-06-21T08:25:19.346-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='overloading'/><category scheme='http://www.blogger.com/atom/ns#' term='inheritance'/><title type='text'>PHP5: inheritance and overriding</title><summary type='text'>example of inheritancefigure -&gt; rectangle -&gt; square figure -&gt; triangleoverriding:methods overriding: "rectangle" and "triangle" override getArea() method (declared in the superclass abstract "figure")to override a method you MUST declare it with the same signature (name + number + arguments sequence)superclass method calling: figure declare a method to get area and a contructor, overridden in the</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/3344533851319398218/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/php5-inheritance-overriding-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3344533851319398218'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/3344533851319398218'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/php5-inheritance-overriding-and.html' title='PHP5: inheritance and overriding'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-2533662640963863641</id><published>2009-06-04T06:38:00.000-07:00</published><updated>2009-11-03T15:11:46.486-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='static'/><category scheme='http://www.blogger.com/atom/ns#' term='methods'/><category scheme='http://www.blogger.com/atom/ns#' term='properties'/><title type='text'>Static members and methods in PHP5</title><summary type='text'>PHP5 supports "static" features, in according to OOP principles.Note: visibility (private, protected, public) rules for static properties/methods are THE SAME AS common ones.----------------------------------------------------Static properties and methods of a class:don't need an instance of the class to use themcallable specyfing classname, followed by "::" and the property  name (including the </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/2533662640963863641/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/static-members-and-methods-in-php5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2533662640963863641'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/2533662640963863641'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/static-members-and-methods-in-php5.html' title='Static members and methods in PHP5'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-4309901099701290032</id><published>2009-06-04T06:12:00.000-07:00</published><updated>2009-11-03T15:09:27.066-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='object'/><category scheme='http://www.blogger.com/atom/ns#' term='reference'/><category scheme='http://www.blogger.com/atom/ns#' term='overridind'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><category scheme='http://www.blogger.com/atom/ns#' term='clone'/><title type='text'>PHP5: object references, object cloning and __clone()</title><summary type='text'>Let's make a simple class with a value (default=1), set and get methodsclass Obj{private $var=1;public function setVal($var) { $this-&gt;var = $var; }public function getVal() { return $this-&gt;var; } }Following, another class that includes the previous one (Or better, it includes a reference to the  previous class, and the object will be instantiated by the constructor)class A{private $obj; //</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/4309901099701290032/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/php5-object-references-object-cloning.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4309901099701290032'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/4309901099701290032'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/php5-object-references-object-cloning.html' title='PHP5: object references, object cloning and __clone()'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-5677860349488332437</id><published>2009-06-04T03:57:00.000-07:00</published><updated>2009-06-21T08:05:21.337-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='value'/><category scheme='http://www.blogger.com/atom/ns#' term='arguments'/><category scheme='http://www.blogger.com/atom/ns#' term='php4'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><category scheme='http://www.blogger.com/atom/ns#' term='passing parameters'/><category scheme='http://www.blogger.com/atom/ns#' term='copy  reference'/><title type='text'>passing parameters to function: PHP4 and PHP5</title><summary type='text'>VariablesIn PHP4 and PHP5,  variables  by default are passed by value (copy) to functions. It means that outside the function the variables don't change$v = 1;function increment($v) { $v++; }increment($v);print $v; // 1 !!If you want to pass by reference, use the operator &amp;$v = 1;function increment(&amp;$v) { $v++; }increment($v);print $v; // 2 !!Objectsby default:PHP4: object passed by valueinside </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/5677860349488332437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/passing-parameters-to-function-php4-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/5677860349488332437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/5677860349488332437'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/passing-parameters-to-function-php4-and.html' title='passing parameters to function: PHP4 and PHP5'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-8718061369496301256</id><published>2009-06-04T03:24:00.000-07:00</published><updated>2009-11-03T15:07:39.345-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='inheritance'/><category scheme='http://www.blogger.com/atom/ns#' term='class'/><category scheme='http://www.blogger.com/atom/ns#' term='protected'/><category scheme='http://www.blogger.com/atom/ns#' term='access'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><category scheme='http://www.blogger.com/atom/ns#' term='abstract'/><category scheme='http://www.blogger.com/atom/ns#' term='public'/><category scheme='http://www.blogger.com/atom/ns#' term='private'/><title type='text'>abstract classes in php5</title><summary type='text'>abstract class:you CANNOT instantiate it, you can ONLY INHERIT it !some methods (at least one) are abstract and the subclass which inherit from it must implement its abstract methods (same visibility, name and arguments)note: the subclass can access all the protected (and public)  methods and members (NOT the private ones) of the superclass !simple  explanatory example://abstractabstract class </summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/8718061369496301256/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/abstract-classes-in-php5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8718061369496301256'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/8718061369496301256'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/abstract-classes-in-php5.html' title='abstract classes in php5'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7644036371045590440.post-167004231618189056</id><published>2009-06-04T02:48:00.000-07:00</published><updated>2009-11-03T15:06:14.042-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='databases'/><category scheme='http://www.blogger.com/atom/ns#' term='interface'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><category scheme='http://www.blogger.com/atom/ns#' term='db'/><title type='text'>php5 interfaces</title><summary type='text'>PHP5 supports "interfaces".What is an interface ? Basically, it's a definition of a class type with methods. If you implement an interface, you must write all the methods in that interface.Example:Let's suppose there is a "dbConnection" interface, that contains all the methods to db access.Interface  dbConnection{public function __construct($host, $user, $pass, $db);public function query($q);</summary><link rel='replies' type='application/atom+xml' href='http://phpntips.blogspot.com/feeds/167004231618189056/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpntips.blogspot.com/2009/06/php5-interfaces-notes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/167004231618189056'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7644036371045590440/posts/default/167004231618189056'/><link rel='alternate' type='text/html' href='http://phpntips.blogspot.com/2009/06/php5-interfaces-notes.html' title='php5 interfaces'/><author><name>elvis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_MN8voSaLS2M/SwbuW1A90ZI/AAAAAAAAGmM/mOHXLaCldTY/s1600-R/1c38163.jpg'/></author><thr:total>0</thr:total></entry></feed>
