PHP 4 and PHP 5

This is a discussion on PHP 4 and PHP 5 within the PHP Language forums, part of the PHP Programming Forums category; What is main difference between PHP 4 and PHP 5? Is possible to use object programming apporach with PHP4? Is ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-01-2005
ablyplus
 
Posts: n/a
Default PHP 4 and PHP 5

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


Reply With Quote
  #2 (permalink)  
Old 01-01-2005
Tony Marston
 
Posts: n/a
Default Re: PHP 4 and PHP 5


"ablyplus" <ablyplus@yahoo.com> wrote in message
news:cr5n6g$5bp$1@ls219.htnet.hr...
> What is main difference between PHP 4 and PHP 5?


take a look at http://www.zend.com/php5/

> Is possible to use object programming apporach with PHP4?


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.

> Is possible to use Stored Procedures in Oracle with PHP4?


Read the manual. take a looki at http://www.php.net/manual/en/ref.oci8.php
at scroll down to example 2.

> Where I can get more informations?


Looking for it might be a start.

> Thanks in advance


You're welcome.

--
Tony Marston

http://www.tonymarston.net



Reply With Quote
  #3 (permalink)  
Old 01-03-2005
Hynee
 
Posts: n/a
Default Re: PHP 4 and PHP 5


"ablyplus" <ablyplus@yahoo.com> wrote in message
news:cr5n6g$5bp$1@ls219.htnet.hr...
> What is main difference between PHP 4 and PHP 5?

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.

> Is possible to use object programming apporach with PHP4?

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.

> Is possible to use Stored Procedures in Oracle with PHP4?

No clue.

> Where I can get more informations?

Read the php manual chapter on OOP in PHP5.


Reply With Quote
  #4 (permalink)  
Old 01-04-2005
Henk Verhoeven
 
Posts: n/a
Default Re: PHP 4 and PHP 5

Hi,

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
http://www.hotscripts.com/PHP/Script...ork/index.html.


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
see http://www.phppeanuts.org/site/index.../92/error.html

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
http://www.php.net/manual/en/ref.oracle.php. Also see
http://www.php.net/manual/en/ref.oci8.php, look for "Example 2. Using
Stored Procedures".

Greetings,

Henk Verhoeven,
www.phpPeanuts.org.

* just an opinion ;-)

ablyplus wrote:

> 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
>
>

Reply With Quote
  #5 (permalink)  
Old 01-21-2005
tslettebo@hotmail.com
 
Posts: n/a
Default Re: PHP 4 and PHP 5

> 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 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.

> 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*.


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
itself).

> - 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.


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
scope.

Regards,

Terje

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:00 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0