Tag: php

How to handle browser redirections in PHP and preventing loops

When programming web applications it happens that I need to redirect a user from one url to another. One example is when the user has made a payment and is redirected back from the payment provider’s portal to my summary page. In that situation I don’t want the user to stay on that page with




Enum support in PHP

As any PHP developer knows, there is no native enum support in PHP due to the fact that PHP is a dynamic language where a variable can be anything and everything. Many have tried to implement their own version of enum support, some solutions working better than others. Here, I’ll give you my version of


Tags:


Data type overview in phpDocumentor

Why is it good to create documentation? Especially if you’re the only coder in the project! You always have this issue of what happens when someone else is going to take over your code in the future. But besides that, if you have a smart IDE you can get a lot of extra help in




Create your own MySQL query profiler in PHP

Do you know how many times your PHP scripts are calling the database or how long time the queries take to execute? Maybe it’s time to create your own query profiler? It’s simpler than you might think. There are several ways of doing it but we’ll look into one example here based upon a previous




How to automatically recover from an MySQL SERVER HAS GONE AWAY error

The error message is very self explaining – the program lost connection to the server. The reason for this error is quite often simply that the script took longer time to execute than the time-out settings in the connection. In PHP there is a simple command to check if the database connection still is open:




Do you know how crash-prone your PHP script is?

It’s easy to spot errors when they happen on your developer machine. But how do you deal with error happening on the live server? Or even more important – how do you discover errors happening to your customers? In PHP you have to possibility to register a function that will be called every time your




%d bloggers like this: