Check out "Do you speak JavaScript?" - my latest video course on advanced JavaScript.
Language APIs, Popular Concepts, Design Patterns, Advanced Techniques In the Browser

# PHP

ExpressionEngine: thumbnail could not be created for the image under Windows

posted in PHP on 2013-11-28   file windows thumbnail file upload preferences image created

I'm a Windows user and I'm working on a ExpressionEngine based site. I'm using EasyPHP as a server and everything works as expected. However, once I decided to upload a file I got "Thumbnail could not be created for the image. Please make sure the thumbnail directory is writable.".

read more

PHP: please, please, clear my cookies

posted in PHP on 2013-10-31   time cookies result arr setcookie request_ids time setcookie app_request_type time store needed

I'm currently working on a JavaScript application which is using the facebook API. There are some things which I need to pass from one page to the other. So, I decided to use cookies. The storing works like a charm, but the deleting doesn't. I needed one hour to find the exact problem.

read more

PHP: simple captcha script

posted in PHP on 2013-08-08   array code expression alphabet result im

In my company, we have a lot of WordPress sites. Some of them require contact form with captcha field. The short way for solving such task is to use a plugin. However, as you may guess, the add-ons are available for everyone, which means that they could be easily explored and probably hacked. That's why I suggested a simple, custom script, which is developed by us.

read more

Deploying ExpressionEngine based site

posted in PHP on 2013-06-25   php file database config files dblogger sql local operations define

I found ExpressionEngine framework very good. It brings the flexibility which I need and still has a good amount of features. However, as many other similar tools, the deployment could be a little bit difficult.

read more

Importing huge MySQL dump under Windows.

posted in PHP on 2013-06-17   mysql dump table hugedump sql sql table hugedump root h localhost u root h mysql command

I just received a 250MB dump of a database and I needed to see what is it inside. As you may guess, PHPMyAdmin is not a good option in this case. I decided to use the command line.

read more

mod_rewrite, one simple rule and two stupidly lost hours

posted in PHP on 2013-06-05   public favicon png index php directory htaccess file server request mod_rewrite

Ok, I should admit that mod_rewrite and regular expressions are not my strongest part. Today - as every other day I realize how little knowledge I have. Actually it's good to have such moments. I lost almost two hours fighting with a really really simple mod_rewrite rule in my .htaccess file.

read more

A short review of ExpressionEngine framework

posted in PHP on 2013-05-20   short review expressionengine framework s capabilities tech pro account article made project start

I'm going to start a new project with ExpressionEngine. So, I made a short review of the framework's capabilities. The article is available at my account in tech.pro.

read more

Cleaning up <pre> tag content

posted in PHP on 2013-02-02   code newstr pre parts2 code str_replace br parts str code code str_replace br code code

I'm blogging for different technologies, but very often I need to add some code in my articles. This little PHP function helps me to keep the text in my

 tags clean for prettify. It simply removes the 
's and keeps the html tags.

read more

PHP developers - wake up!

posted in PHP on 2013-01-16   code time things framework don t good modules writing people big

PHP is one of the most popular back-end solutions available. However, I think that there is something wrong with the way we are using it. It is really popular to use some giant framework, with a lot of features. Generally, I'm not a big fan of this approach. Even if the framework is well documented and has big community it still adds some restrictions and complexity. Many people are trying to build the perfect framework, which covers as many cases as possible, but the true is that it is not possible. In this article I'll present you my vision about PHP programming and I will be very happy if you share yours.

read more

Discussion about PHP at VarnaLab

posted in PHP on 2012-11-22   varnalab php discussion

A screen capture of the discussion about PHP at VarnaLab.

read more

PHP: the right way

posted in PHP on 2012-07-09   php bad http www phptherightway web http www accepted coding standards practices accepted coding read quick reference propagating bad practices astray propagating bad users astray propagating

There’s a lot of bad information on the Web (I’m looking at you, W3Schools) that leads new PHP users astray, propagating bad practices and bad code. This must stop. PHP: The Right Way is an easy-to-read, quick reference for PHP best practices, accepted coding standards, and links to authoritative tutorials around the Web.http://www.phptherightway.com/

read more

Dependency Injection in PHP. Create your own DI container.

posted in PHP on 2012-05-12   class key view show arguments array content navigation title skills

By my opinion one of the biggest problems in programming are dependencies. If you want to have a good well written application you should avoid dependencies between your modules/classes. There is a design pattern which could help and it's called Dependency Injection (DI). It allows you to inject objects into a class, instead of creating them there.

read more

PEAR PHP Coding Standarts

posted in PHP on 2012-02-29   pear en standards php manual en standards net manual en php net manual pear php net http pear php folks http pear pear folks http distribution coding standards

The PEAR Coding Standards apply to code that is part of the official PEAR distribution. Coding standards often abbreviated as CS among developers and they aim to keep code consistent to be easily readable and maintainable by most of PEAR folks.http://pear.php.net/manual/en/standards.php

read more

MySQL vs JSON file data storing

posted in PHP on 2012-02-12   records requests data json ms time request mysql res count array function

I'm not exactly a performance perfectionist, but currently I'm working on a tool which will be used in a large system. It will deliver texts to a multi-language environment and there will be several sites/apps which will performe big amount of request to it. It is the right moment for me to choose how to speed up my code and the work of the tool overall.

read more

Basic PHP authentication

posted in PHP on 2011-10-17   php_auth_pw php_auth_user password username works

The .htaccess file is actually a possible solution for this purpose. The problem with this approach is that the value of AuthUserFile should contain an absolute path. It also works with relative paths, but it is relative based on ServerRoot, which in most of the cases is different from DocumentRoot. I also didn't want to deal with sessions or cookies and after a short research I found the answer.

read more

\"This page contains both secure and non secure items\" message

posted in PHP on 2011-05-26   content problem http page featureloader js php https protocol

When you are opening a site via https protocol and there are items loaded with absolute addresses started with http some browsers, like IE, throw a message This page contains both secure and non-secure items. It is really annoying and if the user decides to can prevent these items of showing and he can brake the whole layout or some functionality.

read more

PHP: add text to transparent PNG image

posted in PHP on 2011-03-10   im digit image png font originalimage php width

Simple way to produce numbered image with PHP. The script uses PHP GD.

read more

PHP: convert emails to mailto links

posted in PHP on 2011-02-17  

It looks like an easy task, but I decided to share it.

read more

PHP: Simple javascript obfuscator (merging files)

posted in PHP on 2010-12-30   jsstr jsstr jsstr str_replace jsstr str_replace jsstr str_replace jsstr jsstr js files fh file comment js core plugins

Currently I'm working on a big JavaScript project. It has a lot of files that have to be compressed. I wrote a simple php class that merges all the files into one. It has also a useful simple obfuscator method.

read more

PHP: export data to XLS file

posted in PHP on 2010-12-01   xlswritelabel echo pack 0x0 function content type application header content type download header content row col 0x0 echo pack ssssss

Sometimes it is necessary to present your data in format which is popular and easy to work with. In most cases the CSV format will fit perfectly you and your clients, but sometimes you have to export the information in XLS file. These several functions will help you to do that.

read more

PHP: find links in a string and replace them with actual html link tags

posted in PHP on 2010-11-24   urlstoreplace str numofurlstoreplace urls alreadyadded numofurlstoreplace count urlstoreplace html link tags

Currently I'm working on an application that gets data from Twitter. The tweet's string contains links that have to be transformed into html link tags. Here is a simple PHP function that helped me.

read more

Remove html tags from a string wtih PHP

posted in PHP on 2010-11-12   str tag remove str return str ius str return

Sometimes you don't need any formatting. That's just a nice way to remove all the html tags.

read more

How to import images directly into the html code (base64)

posted in PHP on 2010-11-11   base64 file html css small form data fp image
read more

How to display php errors when display_errors is set to off

posted in PHP on 2010-09-17   display_errors ini_set server lines found set

I successfully finished an interactive project for one of my clients. We did a great job and finally I had to install the system on their server. I received the FTP and MySQL information from their IT team, but when I uploaded all my files the site didn't work at the first time. The server didn't show any errors and I wasn't able to find out the problem.

read more

Export mysql data to SQL script or CSV

posted in PHP on 2010-09-04   server data mysql export good solution phpmyadmin didn t work export data php file mysql exe mysql server received host

Yesterday I received host name, user name and password for a MySQL server. I needed to export the data from it. I didn't have access to PHPMyAdmin, I tried to connect to the server by mysql.exe on my PC, but it didn't work. And then I found really good solution - PHPMyAdmin in only one php file. I launched it from my localhost and it works. So if you need to export data or just see it, use Adminer. I also uploaded the file on my server, you can download it from here.

read more

How to exclude directory from .htaccess file

posted in PHP on 2010-06-17   htaccess file

Did you ever wonder how to exclude a directory from a .htaccess file. Here is the solution, it works perfect for me.

read more