PHP 4 and PHP 5

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
What is main difference between PHP 4 and PHP 5?
Is possible to use object programming apporach with PHP4?
Is possible to use Stored Procedures in Oracle with PHP4?

Where I can get more informations?

Thanks in advance

Re: PHP 4 and PHP 5

Quoted text here. Click to load it

take a look at">

Quoted text here. Click to load it

Yes. The new features in PHP 5 are mainly cosmetic (e.g. visibility). With
PHP 4 you can define classes with methods, properties and constructors. You
can create objects from these classes at runtime. You do not *need* PHP 5 to
write object oriented code with PHP.

Quoted text here. Click to load it

Read the manual. take a looki at
at scroll down to example 2.

Quoted text here. Click to load it

Looking for it might be a start.

Quoted text here. Click to load it

You're welcome.

Tony Marston

Re: PHP 4 and PHP 5

Quoted text here. Click to load it
Much improved OO, and the odd incompatibility. The only noticeble one is
that array_merge must be given 2 arrays, you can just chuck in a simple
variable and expect it to be merged with an array. It chucks a warning I
believe, and still does it.

Quoted text here. Click to load it
The OO part goes a long way to supporting static methods, variables and
constants. In PHP4, you could call a method statically
(ClassName::Function()) or from an instance (Object->Function()), it didn't
care. PHP4 doesn't support static variables or class constants. To finish
off this static class business, they also add self:: and parent::. self is
the static analogy to $this, and parent:: is how you call a parent class's
function, useful in constructors.
There's also visibility, public private and protected, plus most standard
C++ object stuff, like the final keyword, abstract, extends, and the ability
to implement and interface, which is just a dumb template for how the class
should look.
That said, you can still do heaps of OO stuff in PHP4, it's just more
'correct' in PHP5.

Quoted text here. Click to load it
No clue.

Read the php manual chapter on OOP in PHP5.

Re: PHP 4 and PHP 5


Yes, you can do OOP in php4. I have been doing OOP for over 10 years,
first in Smalltalk, then in java, now in php. Smalltalk was probably the
first real OO language and it still is one of the simpelest, purest and
most powerfull ones. Both php4 and php5 are easier and more effective
for OOP then Java (and C++) because, like Smalltalk, php has weak typing
and because weak typing also works with primitive datatypes (these
allways give you headaches with Java). I wrote an entire OOP framework
in php4 and i am not the only one, see .

In a way php4 is actually more like Smalltalk then php5, because it does
not mess up your mind with nonsense like public, private, protected,
interfaces etc*. But it has two major limitations:
- it implicitly copies objects whenever passed or assigned by value. You
can work around this by allways using references with objects,
- it has no exceptions (try-catch). This is not a big problem for simple
code becuase you will get a reasonable error message and line number,
but if you really do reuse code, the line numbers pointing to the reused
code give little clue about the code that really causes the error. This
makes it hard to debug. It can be worked around too, but that causes
more error handling code in places you do not want it. For the workaroud

You can also write code that runs equally (i mean: does the same) on
both php4 and php5. You only need a small wrapper function library and
some coding guidelines. For these download the PHP 5 portable release.
The coding guidelines are in readme.html. The wrapper library is in
classes/pnt/pntPhp4Functions.php and pntPhp5Functions.php, which are
included from classes/pnt/generalFunctions.php. The wrapper library also
  explains (partly in the form of code) the main differences between OOP
in php4 and php5.

PhpPeanuts does not work with Oracle. Php4 does, see . Also see , look for "Example 2. Using
Stored Procedures".


Henk Verhoeven,

* just an opinion ;-)

ablyplus wrote:

Quoted text here. Click to load it

Re: PHP 4 and PHP 5

Quoted text here. Click to load it

I don't understand what you mean here. In what way can you use
primitive types in PHP, that you can't in Java? It seems to me that PHP
is using almost entirely the same OO model as Java.

Quoted text here. Click to load it

You may be confusing simple with simplistic. Being able to specify
access levels provides compiler-enforced documentation to the
maintainer and user of the code. When you specify something as private,
you can be sure that it can't be called outside the class, thus
avoiding a lot of potential erroneous use. It also means that users of
the class only need to concern themselves with the public interface (or
public and protected, if they want to inherit from it), thus avoiding
distraction from irrelevant (from the user's perspective)
implementation details. Thus, these may make it _easier_ to program.
Unless you think that becoming a better programmer is "messing up your
mind", that is. ;)

Separating interfaces from implementation is a rather fundamental comp
sci concept, and if you consider that "messing up your mind", then,
well, it seems you have some schooling to do (despite what you say
about your years of experience. Some people just stop learning, it
seems, so number of years of experience is rather irrelevant by

Quoted text here. Click to load it


You can use debug_backtrace(), with an appropriate decoding to text, to
improve this, as it gives the stack trace all the way back to global



Site Timeline