Category Archives: PHP

Learn PHP – How to Write A Class in PHP

This article represents some high-level concepts and a code example on how to write a PHP class and use it elsewhere. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Following are some of the key points described later in this article: Why write a PHP class? Key aspects of a PHP class A PHP class – Code Example Using PHP class in PHP files   Why Write a PHP Class? As a beginner, I have come across this common thing that PHP developers tend to write one or more functions in the PHP files/scripts. As a matter of …

Continue reading

Posted in PHP, Web. Tagged with .

PHP – How to Install Apache 2.4 with PHP 5.6 on Windows

This article represents instructions on what’s needed to be done to install Apache 2.4 with PHP 5.6 on Windows (64-bit). Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Following are the key steps/points described later in this article: Install Apache 2.4 Install PHP 5.6 Configure Apache 2.4 for PHP Configure PHP 5.6 Test Install Apache 2.4 This step looks to be obvious. However, after I am done with the entire installation, it looked to be a bit tricky especially when you got 64-bit Windows. If you go to website, http://httpd.apache.org, you are taken to download page for win32 …

Continue reading

Posted in PHP, Web. Tagged with .

Top 10 PHP Code Review Tips

php_code_review_best_practices

This article represents top 10 areas to consider while you are taking up the task to do the code review of a PHP project. The other day, I had a discussion with one of the PHP senior developers who asked me about where to start on the task related with reviewing a PHP web application and, we brainstormed and came up with the list. Interestingly, apart from few, most of them can be pretty much applied to applications written with other programming languages as well. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Following are the key points described later …

Continue reading

Posted in PHP, Software Quality. Tagged with , .

Why Facebook’s Hack May Fail to Fly With PHP Developers?

Well, for those innocent souls, I must make it clear that the title of this article has no intentions to point out that Facebook is hacked or so? This is actually about the new programming language, HACK, that Facebook officially launched few days back. Overview of Hack Language Before I go on to write further, I must thank the Facebook engineering team to have rightfully identified some of the short-comings of PHP programming language and tried to present solutions to them using Hack programming language. However, while I was going through the changes that they made by adding new features to PHP and made it as Hack language, I wondered whether …

Continue reading

Posted in News, PHP. Tagged with .

How to Debug PHP Code?

How to Debug PHP Code

[adsenseyu2] If you have started on PHP programming and looking out for tips and techniques on how to debug PHP code, following may help you get started: var_dump command: var_dump command helps one to explore whats stored in arrays and objects. Following is the sample code: <?php $a = array(1, 2, array(“a”, “b”, “c”)); var_dump($a); ?> echo command: You could as well use the echo command to debug php program flow. <?php $foo = “foobar”; echo “foo is $foo”; ?> Configure Xdebug with Zend Studio or Eclipse PHP IDE: If you are tired of var_dump or echo commands, and write PHP code using IDE such as eclipe-php or Zend Studio, …

Continue reading

Posted in PHP. Tagged with , , .

PHP Code Smells and Best Practices

As application in PHP can be written in object oriented manner, most of the code smells found in the world of object-oriented programming also stay valid for PHP. Recently, I happened to do a code review of a PHP project and wanted to share some of the areas which one would want to pay attention to: Naming methods using Camel Case: It is always helpful to write method names in camel case as it is easily readable. For example, instead of writing method names such as “searchurlAction”, one could write “searchUrlAction”. Software quality characteristic impacted in “Usability“. Long Methods: One may want to avoid large method as these methods become …

Continue reading

Posted in Code Review, PHP, Software Quality. Tagged with .