PHP 4 and 5 compatibility issues
Posted: Wed Feb 28, 2007 7:29 pm
Ok, basically what I am wondering is if there is a equivalent PHP "thing" to the "preprocessor directives" one can use in C/C++. I know that PHP is not compiled and hence no preprocessing. So, maybe it would be better if I explained exactly what I am trying to do.
I have several classes which are written for PHP 5, and I would like to make them compatible with PHP 4. Now, for the most part they are compatible, but in areas of class definitions is where I get my errors. So here is an example of what I want to do.
*** PLEASE USE CODE TAGS ***
---------------------------------------------------------------------
PHP 5 code:
PHP 4 code:
What I want to happen (SUDO-CODE):
---------------------------------------------------------------------
Now, I know the PHP 4 code is compatible with PHP 5, but I would like to be able to use the private/public keywords if capable.
Anyways, I would appreciate any light anyone could shine on this. If this question has already been answered somewhere on the forum, I appologize for not search and finding it, but I do not even know what keywords I could use to find this.
I have several classes which are written for PHP 5, and I would like to make them compatible with PHP 4. Now, for the most part they are compatible, but in areas of class definitions is where I get my errors. So here is an example of what I want to do.
*** PLEASE USE CODE TAGS ***
---------------------------------------------------------------------
PHP 5 code:
Code: Select all
class test1
{
private $a;
private $b;
//declare functions below
}Code: Select all
class test1
{
var $a;
var $b;
//declare functions below
}Code: Select all
class test1
{
if(!thisIsPHP5)
{
var $a;
var $b;
}
else
{
private $a;
private $b;
}
//declare functions below
}Now, I know the PHP 4 code is compatible with PHP 5, but I would like to be able to use the private/public keywords if capable.
Anyways, I would appreciate any light anyone could shine on this. If this question has already been answered somewhere on the forum, I appologize for not search and finding it, but I do not even know what keywords I could use to find this.