-
Dependency Injection in PHP. Create your own DI container.
posted in PHP on 2012-05-12 -
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 comments
-
PEAR PHP Coding Standarts
posted in PHP on 2012-02-29 -
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.
comments
http://pear.php.net/manual/en/standards.php
-
MySQL vs JSON file data storing
posted in PHP on 2012-02-12 -
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 comments
-
Basic PHP authentication
posted in PHP on 2011-10-17 -
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 comments
-
"This page contains both secure and non secure items" message
posted in PHP on 2011-05-26 -
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 comments
-
PHP: add text to transparent PNG image
posted in PHP on 2011-03-10 -
Simple way to produce numbered image with PHP. The script uses PHP GD.
read more comments
-
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 comments
-
PHP: Simple javascript obfuscator (merging files)
posted in PHP on 2010-12-30 -
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 comments
-
PHP: export data to XLS file
posted in PHP on 2010-12-01 -
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 comments
-
PHP: find links in a string and replace them with actual html link tags
posted in PHP on 2010-11-24 -
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 comments
-
Remove html tags from a string wtih PHP
posted in PHP on 2010-11-12 -
Sometimes you don't need any formatting. That's just a nice way to remove all the html tags.
read more comments
-
How to import images directly into the html code (base64)
posted in PHP on 2010-11-11 -
A couple of months ago I received an interesting task - to create a small html application for iPhone. To be honest, for me that meant creating a small site with a specific size. Of course I was wrong. Together with couple of small bugs I had to deal with one other requirement - everything had to be in one html file. It was clear how to add the javascript and the css, but what about the images.
comments
The solution was to use base64 encoding. I wrote a small php script that accepts an image and shows me the equivalent in base64 string.
Just browse your image and click "Submit Query".
P.S.
base64 doesn't work in IE
-
How to display php errors when display_errors is set to off
posted in PHP on 2010-09-17 -
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 comments
-
Export mysql data to SQL script or CSV
posted in PHP on 2010-09-04 -
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.
comments
-
How to exclude directory from .htaccess file
posted in PHP on 2010-06-17 -
Did you ever wonder how to exclude a directory from a .htaccess file. Here is the solution, it works perfect for me.
read more comments