Image headers with PHP

If you ever need to send an image file with PHP from the web server to the web browser you need to add an additional header using the header() function so the browser knows it’s an image and not regular HTML. This post looks at the headers you need to use.

Categories PHP

Get a list of all available constants with PHP

PHP has the function get_defined_constants() which allows you to get a list of all the available constants in an array. This post looks at how to use the get_defined_constants() function and example output from it.

Categories PHP

Type casting with PHP

PHP is a loosely typed language and assigns types to variables depending what is assigned to it. Variables coming from get/post and cookies etc are generally cast as strings rather than other types and there are often other times when you need to specifically cast a type in PHP as e.g. an integer. This post looks at how to type cast in PHP and some of the results than can come about from type casting.

Categories PHP

Using the HTTP_REFERER variable with PHP

When a web browser moves from one website to another and between pages of a website, it can optionally pass the URL it came from. This is called the HTTP_REFERER, and this post looks at how to use this variable with PHP.

Categories PHP

Get an image size with PHP

PHP has a function called getimagesize() for getting the width and height from an image. I’m always forgetting the name of the getimagesize() function so I decided to write a post about it and showing some examples and that way maybe I’ll remember in the future…

Categories PHP

phpMyAdmin prevent popup window for query editing

phpMyAdmin by default opens a popup window when you click the "Edit" link underneath a query. I personally prefer to not have a popup window open and this post looks at how to change the default behaviour.

Categories PHP