PHP 5.4 New Features - Traits

December 05, 2012 at 21:22 | 0 comments

Another great thing that has been added to PHP are the traits. They are an old conception in other programming languages such as Java or C++. They are extremely useful in order to write reuseable code and make your life easier. So what we can do, just to make a quick introduction, is to write down a class which is using the properties and methods of two traits.

trait Weapons {
    private $_weapons = array(1 => 'a sword', 2 => 'an axe', 3 => 'a spear');

    public function choose_weapon($id) {
        echo ' using ' , $this->_weapons[$id];

trait Professions {
    private $_professions = array(1 => 'Warrior', 2 => 'Hunter');

class Hero {
    use Weapons, Professions; //here we say which traits our class will have access to

    public function __construct($profession) {
        echo $this->_professions[$profession];

$hero = new Hero(1);


Warrior using an axe

So the deal is that we don't have to extend the Hero class in order to access the traits. And the best thing is that we can reuse the traits as many times as needed. A problem will accure if we create two methods with the same name, but I am pretty sure that it will be fixed very soon!


PHP 5.4 New Features - Built-in Web Server

November 28, 2012 at 11:38 | 0 comments

One of the new things that I like most in PHP is definitely the built-in webserver feature. But do not think of it as a replacement of the very popular Apache or Nginx web servers. It has been created for development purpose only and you should never use it in production.

You can start your PHP web server via the command line of your computer. There shouldn't be any problems as long as you have PHP version 5.4 above. Simply type:

php -S localhost:80

Note that you must specify which port to be used.

You can start a specific file or directory on your server by adding the path at the end, after the port number.

php -S localhost:80 /subdirectory/another_subdirectory/my_file.php


There is a big chance that you will get an error if you are on Windows:

'php' is not recognized as an internal or external command, operable program or batch file.

This is because you have tell Windows manually how to deal with "php". You can fix this by adding an environment variable to your system.

1. Open System Properties by typing in the start menu "View advanced system settings" or navigate to there by right-clicking the My Computer menu -> Properties -> Advanced System Settings -> Environment variables;

2. Find the system variable Path and click Edit.

3. Add your the path to your php directory at the end of the Variable value, separating with a semicolon.


Why Using MySQL Functions Is Bad?

November 22, 2012 at 22:41 | 0 comments

First of all, let us to get clear which exactly are the MySQL functions. link

So why I say that they are bad to use? Well I personally do not. PHP is changing, so is every other language. After about 10 years of successful usage, these functions are officially deprecated and some day they in the bright future they will be removed.

What should I use then? There are many other ways to manage your database. suggests us to use the MySQL Improved Extension and PDO (PHP Data Object). Not to mention what kind of advanced ORMs (Object-Relational Mapping) exist.

Try not to use these functions anymore. With some little bit of digging into, for example, PDO you will understand the difference and you will not regret for doing so.


Just to show that I'm alive

October 18, 2012 at 23:18 | 1 comment

It's been a while since I made my last post. My job and education were talking all of my time and I barely wanted to walk around here.

But on the other hand, it's been almost two months since I quit my job. Now I have a lot more free time and, perhaps, I could actually work on expanding this place. At least I finally stopped the irritating bot spam that was buzzing me out in the past few months. Also I will probably try to do some freelancing to fill out my free time during university and earn some money to pay my taxes. Wish me luck on this one. :)

And the last thing I want to mention is that I am very eager to make some video tutorials to share my humble knowledge with you people. The biggest problem is that I really don't like my diction, so I will not make any promises for now.


List of Irregular Verbs in English

May 20, 2012 at 23:44 | 0 comments

A list of most verbs in English. It's the perfect weapon for exams (+ mobile support)!


EXIF and PHP, how to find where have you been

April 16, 2012 at 18:51 | 0 comments

This post got my attention (link). I won't talk about conspiracy theories and stuff. I knew that images store some kind of personal information but I didn't know how to extract it and may be I never asked myself how to do it. So after I saw this post by Gatakka, I decided to dig into the deep and do something creative:

It's very simple actually and it took me several hours to build it. All you need to know is how to work with exif_read_data function. Here's the class that makes the big deal. I hope you'd like it:

class Exif {

    private $_lat = 0, $_long = 0;
    private $_basicInfo = array();

    public function checkExif($img) {
        $arr = exif_read_data($img, 'GPS');
        $this->_basicInfo = array(
            'Model' => $arr['Model'], 'Produced by' => $arr['Make'], 'Date taken' => $arr['DateTime'],
            'Sixes' => $arr['COMPUTED']['html']
        if ($arr) {
            $this->_lat = explode('/', $arr['GPSLatitude'][1]);
            $this->_lat = $this->_lat[0] / $this->_lat[1];
            $this->_long = explode('/', $arr['GPSLongitude'][1]);
            $this->_long = $this->_long[0] / $this->_long[1];

            //get degrees
            $dlat = explode('/', $arr['GPSLatitude'][0]);
            $dlong = explode('/', $arr['GPSLongitude'][0]);
            //get seconds
            $slat = explode('/', $arr['GPSLatitude'][2]);
            $slong = explode('/', $arr['GPSLongitude'][2]);

            $this->_lat = $this->_calc($dlat[0], $this->_lat, $slat[0]);
            $this->_long = $this->_calc($dlong[0], $this->_long, $slong[0]);

            if (strtoupper($arr['GPSLatitudeRef']) == 'S') {
                $this->_lat = '-' . $this->_lat;
            } if (strtoupper($arr['GPSLongitudeRef']) == 'W') {
                $this->_long = '-' . $this->_long;
            return true;
        } else {
            return false;

    private function _calc($degree, $min, $sec) {
        //Decimal degrees = whole number of degrees, plus minutes divided by 60, plus seconds divided by 3600
        return number_format($degree + ($min / 60) + ($sec / 3600), 5);


It doesn't work with every single picture. First, file format should be either tif or jpg and second - the image must contain GPS information. Have fun using it! :)


date function, how can I display a non-english name of a month

March 15, 2012 at 22:33 | 0 comments

The function date gives us pretty nice features when working with time and dates. Working with this function makes things so easy. But there is one little problem for those who are going to use the function with a language other than English. It took me some time before I could figure out how could I possibly display month names in Bulgarian language. It is actually very easy and it works every language.

The problem is that when you open the documentation, you see a huge list of all available date formats. And then you keep look for the thing that exactly fits your taste (or at least I used to do that). But it looks like that not everything is written in the Internet and sometimes you just need to work it out on you own:

echo date('J', time()); //outputs the current month, by this time March

Hey wait, I want cyrilic? No problem, here you go:

$array = [1 => 'Януари', 2 => 'Февруари', 3 => 'Март', 4 => 'Април', 5 => 'Май', 6 => 'Юни', 7 => 'Юли', 8 =>  'Август', 9 => 'Септември', 10 => 'Октомври', 11 => 'Ноември', 12 => 'Декември'];

//php 5.4 supports shorter way to create arrays, fuck yeah!

And now instead of showing the exact month, we should use the n format which will output the number of the month (1 to 12):

echo 'The current month is ' . $array[ date('n', time()) ];

Using the same way you can create an array for the days of the week and have more fun.


iWebKit or how to create web applications for iPhone

January 21, 2012 at 19:54 | 0 comments

I have always wanted to create applications for telephones. But I never found the time to actually take a look on these SDKs for Android and iPhone. Anyways, a few days ago a friend of mine showed me this pretty little thing called iWebKit. It's basically some javascript and css which make your website looks like an iPhone app. Now I have never had an iPhone or any iOS device, but as far as I know, you can add URL links to websites straight on your iPhone's desktop. Which would allow quick access to your app (website). Here's a little demo of one minute work with the iWebKit:

You can create pretty cool stuff with just some basic knowledge in any web programming languages or even simple HTML. As I love to say, the only limit is your own imagination.

One more thing. As some of you may know what webkit is, the answer is yes you need a webkit browser (Google Chrome or Safari). But don't worry as an iPhone user you will have Safari for sure. The application can works not only on iPhone, don't forget that it's a website!

And finally, I should not forget to give some credits to the person who let me know how to create iPhone applications without having a Mac - my dear friend Michael.


OpenFest 2011

November 06, 2011 at 22:46 | 1 comment

Today I visited OpenFest, one event about open source which I hadn't been at.

I wasn't at all presentation and I can't express any competent opinion as a critic, but even if I was there for everything, I would not argue. The fest fed my curiosity. Even though some of the lectures took some of the discussions to a higher level of quality that the normal hacker could not easilty understand. How can I say this, it became something like nerd & geek style. But whatever, there should be people for everything, even for such kind of things.

Despite these interesting presentation, there were two competitions - to build a computer and to make LAN cables. There were also very cheap books by O'Reilly which were really worth paying!

As a last thing I want to say that there was live demostration of 3d open source printer in the entrance of the building. You can create this kind of gadget without any problems at home. For those as me who love this kind of stuff I leave this link and some pictures.


The first post!

September 24, 2011 at 22:39 | 3 comments

Hello and welcome in this website!

The purpose of this place will be educative and enthralling. The main discussions will be about computers, but it won't be the only one. Everything depends of the people who will be visiting this place and how much free time I will have. There is still much work at this project, but so far it looks quite decent.

Also, I am not a native English speaker and because of that you will see MANY grammar and syntactical mistakes in my posts. Please excuse my plainless and stupidity, I am improving myself and I think that this is not a bad place to practise. I am trying to be as correct as possible, but I'm just a human. :)



find me

  • google plus
  • linked in
  • youtube