Show PHP errors

ini_set('display_errors', 1);

You can remember the all Shakespeare’s sonnets, but not those 2 lines.

Need framework? Why not Yii?

What is Yii?

Yii is a high-performance PHP framework, not so complicated like Symphony or Zend.

About performance!

The graph below shows how efficient Yii is. We compared Yii with other PHP frameworks.

In the graph, RPS (request per second) describes how many requests an application can process per second. The higher the number, the more efficient a framework is.

Yii performance

As we can see that Yii outperforms all other frameworks in this comparison. The performance advantage of Yii is especially significant when the widely used APC extension is enabled.

What about Yii features?

  • Model-View-Controller (MVC) design pattern
  • Database Access Objects (DAO), Query Builder, Active Record, DB Migration
  • Form input and validation
  • AJAX-enabled widget
  • Authentication and authorization
  • Skinning and theming
  • Web services
  • Internationalization (I18N) and localization (L10N)
  • Layered caching scheme
  • Error handling and logging
  • Security
  • Unit and functionality testing
  • Automatic code generation
  • Friendly with third-party code
  • Detailed documentation
  • Extension library

all what you need ;)

My personal experience.

To test this framework, i create an online CV –
I have seen it was easy and intresting.
Further development of this project and will write a more detailed description.


If you are looking framework, why not Yii? Easy for beginners and full of features for more advanced users.

SugerCrm: How to disable Ajax for a specific module

You also have option of disabling the AjaxUI for modules or across the entire system.
From 6.3 version, SugarCrm have admin section for disabling the AjaxUI on a per module basis (/index.php?module=Administration&action=ConfigureAjaxUI).
It can also be done manually in the config override with a line like:

$sugar_config['addAjaxBannedModules'][] = "Acounts";

That would cause links to the Acounts module in SugarCrm no longer attempt to load via the AjaxUI, and use the normal URL structure.

If You want, you have also option of totally disabling the AjaxUI with the following code.


Remove duplicate values from an array in PHP

Today’s chalenge: How to remove the duplicate values from a PHP array?

after short search i found solution array_unique.

How this function works:


$input = array(1, 2, 2, 3, 3, 4);

$result = array_unique($input);

var_dump($result); ?>

will output:
array(4) {
[0]=> int(1)
[1]=> int(2)
[3]=> int(3)
[5]=> int(4)

Remember: Output of array_unique() will have the same key of input array.

Google Currents app updated !

US people have been able to use the Google Currents app to read various websites with magazine-style layout.

Now other countries can finally get in on the act as well. Google has release version 1.1 of the app for Android and iOS.

New version makes the service available worldwide with support for 44 languages, adds a number of other improvements:

  • the ability to select which editions have images for offline reading
  • instant online sync
  • translation for 38 languages
  • promised 7X performance boost

And the best – app is completely free, and adapts the layout to suit both phones and tablets.

Scan QR code below to download it for the platform of your choice.

XML to PHP array

Some times when working in PHP you need a way to convert an XML document into a serializable array. If you ever tried to serialize() and then unserialize() a SimpleXML or DOMDocument object, you know what I’m talking about.

Assume the following XML snippet:

<show name="The Simpsons">


I found quick but little dirty way to do convert such axml document to an array, using type casting and JSON functions. After this i can ensure there are no exotic values that would cause problems when unserializing:

$a = json_decode(json_encode((array) simplexml_load_string($tv)),1);

After this we get:

    [show] => Array
            [@attributes] => Array
                    [name] => The Simpsons)
            [husband] => Homer
            [wife] => Marge
            [kid] => Array
                    [0] => Bart
                    [1] => Lisa
                    [2] => Maggie



MIT launchesApp Inventor public Beta

the Android apps creation tool is no longer being managed by Google. MIT worked up its own version.

Now you can go and log into the MIT App Inventor with valid Google ID.

App Inventor lets you develop applications for Android phones using a web browser and either a connected phone or emulator. The App Inventor servers store your work and help you keep track of your projects.

You build apps by working with:

  • The App Inventor Designer, where you select the components for your app.
  • The App Inventor Blocks Editor, where you assemble program blocks that specify how the components should behave. You assemble programs visually, fitting pieces together like pieces of a puzzle.
  • Your app appears on the phone step-by-step as you add pieces to it, so you can test your work as you build. When you’re done, you can package your app and produce a stand-alone application to install.

Converting date in PHP from yyyymmdd to yyyy mm dd format

I have dates in the following format (yyyymmdd, 18751104, 19140722) and i need normal date (yyyy mm dd, 1875 11 04, 1914 07 22).

1. first you can use strtotime and date functions (this will fail with dates before the Unix epoch at the start of 1970. )
// prints 1995 Oct 12
echo date("Y M d", strtotime("19951012"));

2. Alternative which will work with dates before 1970
<?php // Returns the year as an offset since 1900, negative for years before
$parts = strptime("18951012", "%Y%m%d");
$year = $parts['tm_year'] + 1900; // 1895
$day = $parts['tm_mday']; // 12
$month = $parts['tm_mon']; // 10 ?>

3. simple method – date_parse_from_format

<?php $parsed_date = date_parse_from_format('Ymd', $date); ?> 

4. substr because it’s probably the lightest way to do it

mktime(substr($date, 0, 4), substr($date, 4, 2), substr($date, 6, 2));

Delete default input value on click

I hate this task: „Delete default value of an input text on click„. Many times i use code like this

<input type="text" value="" name="email"
onblur="if (this.value == '') {this.value = '';}"
onfocus="if (this.value == '') {this.value = '';}" />

Forget about this! I would recommend you try HTML5 solution below which uses the placeholder attribut.

<input name="Email" type="text" value="" placeholder="" />