This is a discussion on converting code in PHP5 to PHP4 within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, I want to convert pajaj php5 code into php4 code. I removed public and private very easily. But the ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
sam said the following on 01/02/2006 09:46:
> Hi, > > I want to convert pajaj php5 code into php4 code. > I removed public and private very easily. But the static and few others > (can't remember right now) are hard to deal with. How to simulate a > static variable in php4? Well, the simple answer is: don't attempt to use PHP 4 for any kind of sensible OOP, it's simply not geared up to do anything useful in this respect. It's a bit like asking "how can I simulate a static class member using assembler?". However, whilst I'm too drunk to offer anything better, will something like the following be of any use: class Foo { function variable($newVar = NULL) { static $var; if ($newVar != NULL) { $var = $newVar; } return $var; } } Foo::variable(6); echo Foo::variable(); -- Oli |