A new nice improvement in PHP 5.4 As you can see in the news list they added array dereferencing support. What this actually means? If a method of your class returns an array, then to use a specific element you will need another variable. Example: [sourcecode language=”php”] class MyClass { public function giveMeArray() { return… Continue reading Array dereferencing support in PHP 5.4.0
Category: php
Cannot redeclare geoip_country_code_by_name
Today I had this error on my Ubuntu Linux box Fatal error: Cannot redeclare geoip_country_code_by_name() The reason was that I have geoip extension enabled in my PHP configuration and also I used the geoip.inc file from maxmind.com. The solution is very simple. Actually, there are two solutions: First is to disable the geoip extension from… Continue reading Cannot redeclare geoip_country_code_by_name
How To – Activate PHP in public_html for Ubuntu 10
It seems it is a bug (I didn’t investigate too much) in Ubuntu 10.x related to PHP files in userdirs. On my box I have Ubuntu 10.10, Apache/2.2.16 (Ubuntu) and PHP 5.3.3-1. Everything worked fine except the PHP files from ~userdir. Instead to parse these files, the web server send them directly to the browser… Continue reading How To – Activate PHP in public_html for Ubuntu 10
A simple MVC framework
I will describe in the following post a (very) simple MVC framework. You can download the source code from here or can make a copy from bitbucket repository. As you can see, we have the following folders: – web: here resides your public files (images, css, and index.php) – app: here you can find application… Continue reading A simple MVC framework
Singleton Pattern
This pattern is probably one of the most simple and used pattern. As php manual says: The Singleton pattern applies to situations in which there needs to be a single instance of a class. The most common example of this is a database connection. Implementing this pattern allows a programmer to make this single instance… Continue reading Singleton Pattern
Public, Private, and Protected in PHP
or how to manage access to your classes. In PHP there are three levels of access for properties and methods from within a class: public, private, and protected. Public access is the default setting for method and for properties. Public properties and methods can be accessed from any context. Private methods and properties can ONLY… Continue reading Public, Private, and Protected in PHP