Web Hosting Talk







View Full Version : OOP in PHP5


bakhanbeigi
06-03-2005, 02:21 PM
Hello

I am a new user in this site!
and my english is not very good :)

I am learning OOP in PHP and I was write my first code in OO mode tht its in this link:

iieworld.com/class.zip

please see this code and say to me the problems.


thank you

Rotwang
06-03-2005, 03:45 PM
Well everyone's going to jump on me for saying this but I really don't think you should write OOP code in PHP. PHP isn't strong-typed. Anyway, others will disagree. If you're doing it in a class or something I guess you don't have a choice.

Anyway, I downloaded your file I'll take a look at it tonight.

WO-Jacob
06-03-2005, 04:27 PM
Originally posted by Rotwang
Well everyone's going to jump on me for saying this but I really don't think you should write OOP code in PHP. PHP isn't strong-typed. Anyway, others will disagree. If you're doing it in a class or something I guess you don't have a choice.

Anyway, I downloaded your file I'll take a look at it tonight.

:hammer:

OOP is fine in PHP provided that you are using it for the same purposes as everyone elses uses OOP. Simplification of portability, and structuring your application.

If you rely on your programming language to tell you that an int shouldn't be assigned to a string, quite possibly you shouldn't be doing much programming anyway :D

orbitz
06-03-2005, 04:37 PM
Originally posted by Rotwang
Well everyone's going to jump on me for saying this but I really don't think you should write OOP code in PHP. PHP isn't strong-typed. Anyway, others will disagree. If you're doing it in a class or something I guess you don't have a choice.

Anyway, I downloaded your file I'll take a look at it tonight.

you have made yourself a living target for people to jump on you. lolz

you must be kidding to say that we should not need to use OOP in PHP.

Maybe you are talking about a litte program with few hundreds of lines and that you are a bit lazy to use class. :)

I am not an expert myself, but OOP has saved me lots of time. My codes are re-usable!!! and much more - I am lazy to go into details. Any php books can tell you about it.

I suggest you do more programming in PHP with OOP and you see the beauty of it. :cool: ;)

Rotwang
06-03-2005, 04:42 PM
I wrote a whole response to that but I don't want to hijack this guy's thread. If you want me to hammer your smiley, make a new thread and pm me. :uzi: :angel:

orbitz
06-03-2005, 04:43 PM
Originally posted by bakhanbeigi
Hello

I am a new user in this site!
and my english is not very good :)

I am learning OOP in PHP and I was write my first code in OO mode tht its in this link:

iieworld.com/class.zip

please see this code and say to me the problems.


thank you

i gtg, but i had a little time to look at your class:

for logout you may want to do this:

session_unset();
$_SESSION = array();
session_destroy();

orbitz
06-03-2005, 10:15 PM
Originally posted by Rotwang
I wrote a whole response to that but I don't want to hijack this guy's thread. If you want me to hammer your smiley, make a new thread and pm me. :uzi: :angel:

my time is valuable! you can open a new thread and argue with yourself :stickout: :stickout:

dandans
06-03-2005, 10:36 PM
Two reasons not to go with PHP OOP:
There's no naming space support.
PHP objects are very inefficient in memory management (the length of member variable names will affect the bytes taken).

WO-Jacob
06-03-2005, 11:17 PM
Namespace support how?

You can statically referrance classes...

bakhanbeigi
06-04-2005, 01:32 AM
I thing PHP 5 support the name space .

In this file I have 2 class : login and template
I merge the login and template class in another file is it correct?
please tell me the problems of my code

Koobi
06-04-2005, 05:01 AM
PGP5 does support private and public properties.

You merged the login and template class? I would think it's a better idea to leave the two classes as seperate entities and then extend them if you need to...try not to merge the two classes into one, that would defy the purpose of the whole OOP concept.



One very good reason to use OOP: Inheritance

bakhanbeigi
06-04-2005, 05:19 AM
Do you see my code?

I think I used a bad word (merge)

I have 2 class a simple login and a simple template engine!

how can I use this code??

please help me about Inheritance in my code

bakhanbeigi
06-07-2005, 02:52 PM
I am waiting !

Ryan F
06-09-2005, 03:54 AM
Originally posted by bakhanbeigi
I thing PHP 5 support the name space .


No, it does not.

bakhanbeigi
06-24-2005, 03:26 AM
Ok, may be It does not,

Can you help me about my problem?

kuja
06-24-2005, 01:02 PM
Originally posted by Rotwang
Well everyone's going to jump on me for saying this but I really don't think you should write OOP code in PHP. PHP isn't strong-typed. Anyway, others will disagree. If you're doing it in a class or something I guess you don't have a choice.

Anyway, I downloaded your file I'll take a look at it tonight.

The logic still exists. In a language like PHP, that's the purpose of PHP. The OOP logic.

kuja
06-24-2005, 01:03 PM
Originally posted by bakhanbeigi
I thing PHP 5 support the name space .

In this file I have 2 class : login and template
I merge the login and template class in another file is it correct?
please tell me the problems of my code

Name spaces in PHP5 were supported in a development version I believe. But not currently.

EXOWorks
06-25-2005, 08:31 AM
I don't think why people argue over what's better programming practice. It's just your personal preference. Do what you like!!! No one is a perfect coder and you will also never become one because nothing in the world is PERFECT!

Don't always think like those old programmers who followed the rules and standards in all cases. Nowadays, it's just a personal preference. As long as you get what you are trying to achieve, it doesn't matters what type of code you have. At least, it doesn't matters to me. :)

Talking about classes and objects, The advantage of objects is that they can be reused with simplicity.

kuja
06-26-2005, 10:51 AM
In programming, it's not a matter of good or bad practice.

All you need is the logic and efficiency (and perhaps readability).

You can't just say that efficiency isn't a practice, and that practices are just preference.

You make a minor mistake on banking software that causes say: 1 hour downtime, that it coming out of YOUR salary.

What you said can be partially true.

bakhanbeigi
07-02-2005, 05:13 AM
I am sorry but I dont make this topic for argue over OOP!

I maked this topic to find the awnser about my problem.

Maybe some people like me have a problem like me and they can find the awnser here!