PHP Archives

How to create a redirect in PHP

Say you had domain.com/folder, and you’d like it to automatically redirect to domain.com/otherfolder, do the following: Add the above to a file called index.php in domain.com/folder. As soon as someone visits your location, the browser redirects to the new URL. Courtesy of the Stackoverflow community: http://stackoverflow.com/questions/768431/how-to-make-a-redirect-in-php

How to switch between several PHP versions in MAMP 2.x

mamp logoSometimes you need to test your projects against multiple versions of PHP.

If you’re using MAMP that’s fairly easy to do: head over to the MAMP Start Screen, select Preferences and see two versions to choose from.

Here I’m using MAMP 2.2 (even though 3.x has been released already) and I have PHP 5.2.17 and PHP 5.5.3.

When I switch to the other version MAMP restarts and I can refresh my browser to see my project running on the other PHP version.

Screen Shot 2014-03-20 at 08.31.06

Screen Shot 2014-03-20 at 08.31.12

That’s all good if I actually needed either version – but sadly 5.2.x is too old for me, and 5.5.x doesn’t quite work and is a bit too cutting edge. I need it to reflect my production environment.

So what is a boy to do?

Read more

How to check the size of a file in PHP

PHP has a handy function called filesize() which can help us display how big a file is. It does this in bytes by default, but with a bit of tinkering we can easily convert this into kilobytes or megabytes. Let’s first see how this works in bytes: $file = ‘/path/to/your/file’; $filesize = filesize($file); echo “The … Read more

How to add elements to an array in PHP

It’s extremely easy to add elements to an existing array in PHP – so easy in fact that I regularly forget how to do it! I’m used to initialising and setting up my variables from Objective C, but PHP is so much easier and deals with it on the fly. Here we do it – … Read more

Getting Started with ZEND Server 6 on Mac OS X

ZEND_logo

I’ve just installed ZEND Server 6.3 on my MacBook running Mavericks 10.9.1. Needless to say I’m sill a little shaken up from the huge amount of brain pain this adventure has caused.

Because once downloaded and installed on your system, you may ask yourself a vital question: Now What?

Let’s find out. This article is Work in Progress – bear with me while I flesh it out.

The Basics

ZEND Server on Mac is located here:

  • /usr/local/zend/

Your web files live here:

  • /usr/local/zend/apache2/htdocs

To open this directory in Finder you can navigate there with a Terminal session and open it, like so:

cd /usr/local/zend/apache2/htdocs
open .

Now you can create a shortcut on your sidebar for easy access.

To access the ZEND Server Admin interface, navigate to the following URL in your browser:

If you’re done with it, you can uninstall ZEND Server with the following command:

sudo /usr/local/zend/bin/uninstall.sh

Read more