Connecting Tech Pros Worldwide Help | Site Map

OO PHP

Smitro
Guest
 
Posts: n/a
#1: Nov 22 '05
Hi all,

I have spent the last couple of days getting my code up to scratch with
PHP 5 and MySQL 5. (I still don't quite understand why we had to change
to mysqli from mysql)

Just a question, Object Orientated PHP? Is it the way that PHP is
heading, or is it just an addon for those that want to use it.

I started using php because to me it made so much sence. When I look at
the example of Object Orientated PHP I get totally lost. Do I have to
start looking at moving all my code this way, or is this just an addon
for those that are use to coding in this way? What are my chances of
running procedual code in PHP 6?
Erwin Moller
Guest
 
Posts: n/a
#2: Nov 22 '05

re: OO PHP


Smitro wrote:
[color=blue]
> Hi all,
>
> I have spent the last couple of days getting my code up to scratch with
> PHP 5 and MySQL 5. (I still don't quite understand why we had to change
> to mysqli from mysql)
>
> Just a question, Object Orientated PHP? Is it the way that PHP is
> heading, or is it just an addon for those that want to use it.
>
> I started using php because to me it made so much sence. When I look at
> the example of Object Orientated PHP I get totally lost. Do I have to
> start looking at moving all my code this way, or is this just an addon
> for those that are use to coding in this way? What are my chances of
> running procedual code in PHP 6?[/color]

Hi,

Stay cool. :-)
You CAN use OO if you want, but nobody is forcing you to do so.
Many hackers like PHP the way it is, and do not use OO.

Because OO offer some very serious advantages, you can expect to see more
OO-PHP-code, but of course it is up to you if you want to use it.

And PHP is not heading in a direction that forces you to use OO, it is just
offering you the option.

Mind however that many usefull add-ons, like PEAR, are coded in an OO
fashion. If you find you have some time left, use it to study OO.
PHP's implementation of OO is easy to learn (compared to Java eg), and you
might find yourself in the future in the situation you see that
very-handy-impossible-to-resist-package, but it uses OO.


Regards,
Erwin Moller
Oliver Grätz
Guest
 
Posts: n/a
#3: Nov 22 '05

re: OO PHP


No question: You will be able to use procedural code with PHP6!

The developers of PHP are well aware that man people prefer this way of
programming _and_ they want to ensure that clean PHP4 code will be able
to run on PHP6 with little to no modifications. Some of the developers
themselves swear by the procedural way!

Anyway: I prefer OOP. In my early days of PHP I couldn't understand the
need for classes and objects in a language where your program only lives
for a couple of seconds or milliseconds, but now my code base has grown
and classes are _the_ way of easily managing such a lot of code.

And objects are nice:

$meeting_id=14;
$m=new DB_Meeting($meeting_id);
foreach ($m->allParticipants as $person)
{
mail(
$person['email'],
'Invitation to the meeting "'.$m['topic'].'"',
'Dear '.$person['nick']', you are invited!'
);
}

This fetches all the records from the database and iterates through them
without any need for SQL on my side.

OLLi
Malcolm Dew-Jones
Guest
 
Posts: n/a
#4: Nov 22 '05

re: OO PHP


Erwin Moller (since_humans_read_this_I_am_spammed_too_much@spam yourself.com) wrote:
: Smitro wrote:

: > Hi all,
: >
: > I have spent the last couple of days getting my code up to scratch with
: > PHP 5 and MySQL 5. (I still don't quite understand why we had to change
: > to mysqli from mysql)
: >
: > Just a question, Object Orientated PHP? Is it the way that PHP is
: > heading, or is it just an addon for those that want to use it.
: >
: > I started using php because to me it made so much sence. When I look at
: > the example of Object Orientated PHP I get totally lost. Do I have to
: > start looking at moving all my code this way, or is this just an addon
: > for those that are use to coding in this way? What are my chances of
: > running procedual code in PHP 6?

: Hi,

: Stay cool. :-)
: You CAN use OO if you want, but nobody is forcing you to do so.
: Many hackers like PHP the way it is, and do not use OO.

: Because OO offer some very serious advantages, you can expect to see more
: OO-PHP-code, but of course it is up to you if you want to use it.

: And PHP is not heading in a direction that forces you to use OO, it is just
: offering you the option.

: Mind however that many usefull add-ons, like PEAR, are coded in an OO
: fashion.

For the most part, you don't need to "know" OO to use OO libraries.

To use most libraries, OO is just a syntax,

$value_returned_earlier->useful_function_name(my,args,go,here);

Someone said that they like OO, but you have to realize that at some point
in the code, every OO program does plain old procedural programming.

If you are tying things together, and they happen one step at a time, then
procedural code is the thing you need.

Many tasks are best solved one step at a time, possibly using libraries
(which may be OO) to take care of the arcane details.

Closed Thread