[PHP-DB] ways of making access and visib compat with 4 and 5

2005-03-14 Thread tony yau
hi all,

I'm trying to make my classes compat with php4 and php5 is there a way of
doing something like this:

if( version== 4)
define( VISIBILITY,  );
else if (version==5)
define( VISIBILITY, protected );

class Flex
{
 VISIBILITY function CompatFunc();
}
-- 

Tony Yau

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] ways of making access and visib compat with 4 and 5

2005-03-14 Thread Jochem Maas
tony yau wrote:
hi all,
I'm trying to make my classes compat with php4 and php5 is there a way of
doing something like this:
if( version== 4)
define( VISIBILITY,  );
else if (version==5)
define( VISIBILITY, protected );
class Flex
{
 VISIBILITY function CompatFunc();
}
this will never work.
the if/else block is run _after_ the code is compiled.
the line 'VISIBILITY function CompatFunc();' will always
fail because php won't recognise the token 'VISIBILITY'.
not that putting a constant where you do (even if it were
defined) would work anyway.
btw: you could/should have asked this question on php-generals
(there's no reference to DB usage/problems in your question)
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] ways of making access and visib compat with 4 and 5

2005-03-14 Thread Erwin Kerk
tony yau wrote:
hi all,
I'm trying to make my classes compat with php4 and php5 is there a way of
doing something like this:
if( version== 4)
define( VISIBILITY,  );
else if (version==5)
define( VISIBILITY, protected );
class Flex
{
 VISIBILITY function CompatFunc();
}

No, seems to me this is not possible. A trick i'm using is this:
Class Foo {
 /* protected */ function Bar() {}
}
While I'm running PHP4, the class is as above. As soon as I'm switching 
to PHP5, I do a find and replace and remove the comments


Erwin
P.S. This is a database-related malinglist ;)
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php