Creating test environment
In order to have two PHP versions (for example 5.2 and 5.3) available in the same directory you
need to edit .htaccess file located in this directory. Supposing your current version executing .php
scripts is 5.2.17 and you want to try if a script or a group of scripts, classes or functions would
run under 5.3.
Exercise 1:
Add these two lines to the .htaccess file
.htaccess
Action application/x-hg-php53 /cgi-sys/php53 AddHandler application/x-hg-php53 .php53
You have just told the Apache Server to process scripts which carry the extension .php53
(mytest.php53 for example) with PHP 5.3.
You have told nothing about your other .php scripts (the default), so all standard .php files
will be processed by any older PHP version you might have installed, for example by 5.2.17.
Caution:
The parameters for the Action and AddHandler statements vary from
server to server. We are hosting our webs at HostGator and
the examples shown here are real, but you must check with your hoster the exact syntax to be used.
The extention name (.php53 in this example), however, is always up to you to choose.
Testing two PHP versions
Exercise 2:
Create a php script with the code you want to test and save it twice: as .php and .php53, for
example as mytest.php and mytest.php53. The script may include an existing class,
of course. For the test purpose you just need absolutely the same script but
under two different names. For a quick start you can use this chunk of code:
mytest.php
<?php namespace my53; echo 'Hallo El Caribe'; ?>
mytest.php53
<?php namespace my53; echo 'Hallo El Caribe'; ?>
|