Ask a Question related to PHP Development, Design and Development.
-
Sticks #1
classes... why?
why would i use a class in php, and how do i use a class in php?
Sticks Guest
-
new to php classes
Hi everyone, I am new to using classes in PHP development. Can someone tell me if it's possible to use a class inside a class. I am developing... -
two classes
how can I call class b method b, from class a method a ? -
Classes
do you get an error-message? which? maybe you use var $id = array(); instead of var $id; ciao SVEN Patrik Fomin wrote: -
First Go at Classes
So, here I am, I've been programming PHP for 6 years, and have never gotten into classes. Well, I finally decided to take the plunge, and here's my... -
ASP Classes vs COM
For the majority of my work, I just use plain ASP. On the rare occasion that I am doing something intensive that does require user interaction I... -
Sticks #2
classes... why?
why would i use a class in php, and how do i use a class in php?
Sticks Guest
-
sotto #3
Re: classes... why?
On Tue, 12 Aug 2003 17:34:19 +1000, Sticks wrote:
Simplistic: Classes make it easier to write "reusable" code> why would i use a class in php, and how do i use a class in php?
For more information about classes in php... read the manual (there are some
little examples on how to use them)
also search google for OO and php or OOPS and php (Object Oriented)
sotto Guest
-
sotto #4
Re: classes... why?
On Tue, 12 Aug 2003 17:34:19 +1000, Sticks wrote:
Simplistic: Classes make it easier to write "reusable" code> why would i use a class in php, and how do i use a class in php?
For more information about classes in php... read the manual (there are some
little examples on how to use them)
also search google for OO and php or OOPS and php (Object Oriented)
sotto Guest
-
Phil Roberts #5
Re: classes... why?
With total disregard for any kind of safety measures "Sticks"
<strat11@hotmail.com> leapt forth and uttered:
Read this: [url]http://sitepointforums.com/showthread.php?threadid=59898[/url]> why would i use a class in php, and how do i use a class in php?
>
>
--
There is no signature.....
Phil Roberts Guest
-
Phil Roberts #6
Re: classes... why?
With total disregard for any kind of safety measures "Sticks"
<strat11@hotmail.com> leapt forth and uttered:
Read this: [url]http://sitepointforums.com/showthread.php?threadid=59898[/url]> why would i use a class in php, and how do i use a class in php?
>
>
--
There is no signature.....
Phil Roberts Guest
-
Kevin Thorpe #7
Re: classes... why?
Ian.H [dS] wrote:
Because you would probably write checking code inside the class to stop> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Whilst lounging around on Tue, 12 Aug 2003 10:32:40 +0200, Warstar
> <warstar@NSA.com> amazingly managed to produce the following with
> their Etch-A-Sketch:
>
>>>>>>>why would i use a class in php, and how do i use a class in php?
>>because it is great u can get more readable code and better
>>security.
>
>
> How does using classes make things more secure than anything else?
>
> <?php
> class foo {
> function bar($string) {
> system($string);
> return;
> }
> }
>
> foo::bar('rm -rf /');
> ?>
>
>
> How is the above more secure than:
>
>
> system('rm -rf /');
>
the user from making stupid mistakes like that.
Kevin Thorpe Guest
-
Kevin Thorpe #8
Re: classes... why?
Ian.H [dS] wrote:
Because you would probably write checking code inside the class to stop> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Whilst lounging around on Tue, 12 Aug 2003 10:32:40 +0200, Warstar
> <warstar@NSA.com> amazingly managed to produce the following with
> their Etch-A-Sketch:
>
>>>>>>>why would i use a class in php, and how do i use a class in php?
>>because it is great u can get more readable code and better
>>security.
>
>
> How does using classes make things more secure than anything else?
>
> <?php
> class foo {
> function bar($string) {
> system($string);
> return;
> }
> }
>
> foo::bar('rm -rf /');
> ?>
>
>
> How is the above more secure than:
>
>
> system('rm -rf /');
>
the user from making stupid mistakes like that.
Kevin Thorpe Guest
-
Kevin Thorpe #9
Re: classes... why?
Methinks my answer was a little short and didn't explain my meaning> But that's no different from:
>
> $string = 'rm -rf /';
> if ($string != 'rm -rf /') {
> system($string);
> }
>
>
> is it?
>
> My point was just that whatever code you use, beit classes, functions
> or "inline", it's all as secure as you make it, there is no real
> security advantages / disadvantages of using / not using classes if
> you code correctly from the outset.. but if you feel that because
> code is written "inline" it doesn't need checking / validating.. only
> when within a class, then the mind boggles.
properly. In the case of you, Ian, I realise this is a grandmother-egg
situation, but I'll include a full explanation for the original poster.
If I have an application which deals with something like purchase orders
I would have a database table to hold them. At this point I can write my
php scripts to create, modify and write them. If I only need a couple of
short scripts then I would probably include all my error checking in
these scripts.
However, if the application starts to grow larger the amount of checking
performed in each script starts to become unwieldy. There's also a
danger that I might alter the underlying structure of a purchase order
and fail to update the error checking in every script in the
application. This can easily lead to damaged records in the database.
The situation is even worse if someone else has written custom scripts
which I know nothing about.
At this point all handling of purchase orders should be encapsulated
within a class (or library of functions) which contain a definitive set
of error and consistency checks for dealing with a purchase order. If I
alter the structure or rules for a purchase order I change one class
library to reflect this. Incorrectly written scripts will then fail
(hopefully gracefully) without damaging records in the database.
This also helps to protect me from any odd implementation gotchas which
I've forgotten about in the intervening years since I wrote the
application. Writing programs is one thing, maintaining them over a long
period of time (some over 10 years now) is a completely different game.
Anything which helps to clarify your original thinking or stops you
shooting yourself in the foot is of prime importance.
Kevin Thorpe Guest
-
Kevin Thorpe #10
Re: classes... why?
Methinks my answer was a little short and didn't explain my meaning> But that's no different from:
>
> $string = 'rm -rf /';
> if ($string != 'rm -rf /') {
> system($string);
> }
>
>
> is it?
>
> My point was just that whatever code you use, beit classes, functions
> or "inline", it's all as secure as you make it, there is no real
> security advantages / disadvantages of using / not using classes if
> you code correctly from the outset.. but if you feel that because
> code is written "inline" it doesn't need checking / validating.. only
> when within a class, then the mind boggles.
properly. In the case of you, Ian, I realise this is a grandmother-egg
situation, but I'll include a full explanation for the original poster.
If I have an application which deals with something like purchase orders
I would have a database table to hold them. At this point I can write my
php scripts to create, modify and write them. If I only need a couple of
short scripts then I would probably include all my error checking in
these scripts.
However, if the application starts to grow larger the amount of checking
performed in each script starts to become unwieldy. There's also a
danger that I might alter the underlying structure of a purchase order
and fail to update the error checking in every script in the
application. This can easily lead to damaged records in the database.
The situation is even worse if someone else has written custom scripts
which I know nothing about.
At this point all handling of purchase orders should be encapsulated
within a class (or library of functions) which contain a definitive set
of error and consistency checks for dealing with a purchase order. If I
alter the structure or rules for a purchase order I change one class
library to reflect this. Incorrectly written scripts will then fail
(hopefully gracefully) without damaging records in the database.
This also helps to protect me from any odd implementation gotchas which
I've forgotten about in the intervening years since I wrote the
application. Writing programs is one thing, maintaining them over a long
period of time (some over 10 years now) is a completely different game.
Anything which helps to clarify your original thinking or stops you
shooting yourself in the foot is of prime importance.
Kevin Thorpe Guest
-
kafooey #11
Re: classes... why?
On Tue, 12 Aug 2003 17:34:19 +1000, "Sticks" <strat11@hotmail.com>
wrote:
This is probably going to open a Pandora's Box, but after much playing>why would i use a class in php, and how do i use a class in php?
around with PHP I have ended up doing procedural program design rather
than object oriented.
Granted, for complex applications it's going to be handy, but because
PHP has no application level objects, setting any complex data
structures and so on up is a bit of a nightmare because you have to do
it at the start of every page - hardly ideal...
kafooey Guest
-
Louis-Philippe Huberdeau #12
Re: classes... why?
No application level objects? What about SRM?
[url]http://www.vl-srm.net/index.php[/url]
kafooey wrote:> On Tue, 12 Aug 2003 17:34:19 +1000, "Sticks" <strat11@hotmail.com>
> wrote:
>
>>>>why would i use a class in php, and how do i use a class in php?
>
> This is probably going to open a Pandora's Box, but after much playing
> around with PHP I have ended up doing procedural program design rather
> than object oriented.
>
> Granted, for complex applications it's going to be handy, but because
> PHP has no application level objects, setting any complex data
> structures and so on up is a bit of a nightmare because you have to do
> it at the start of every page - hardly ideal...
>Louis-Philippe Huberdeau Guest
-
treefroginometry #13
Re: classes... why?
"sotto" <junk@sotto.be> wrote in message
news:pan.2003.08.12.07.52.02.309390@sotto.be...some> On Tue, 12 Aug 2003 17:34:19 +1000, Sticks wrote:
>>> > why would i use a class in php, and how do i use a class in php?
> Simplistic: Classes make it easier to write "reusable" code
>
> For more information about classes in php... read the manual (there areDoes PHP support inheritance and the like?> little examples on how to use them)
> also search google for OO and php or OOPS and php (Object Oriented)
I too never understood the point of classes but due to HAVING to learn about
C# which is entirely OO, I've found them to be VERY usefull. I'll certainly
be porting my new found OOP knowledge to my PHP work.
BTW - my advice to anybody who doesn't know what classes are for; go and
learn now! The concept can be quite difficult to grasp, but once you have,
you'll wish you learnt earlier.
Regards,
Nathan
treefroginometry Guest
-
treefroginometry #14
Re: classes... why?
"sotto" <junk@sotto.be> wrote in message
news:pan.2003.08.12.07.52.02.309390@sotto.be...some> On Tue, 12 Aug 2003 17:34:19 +1000, Sticks wrote:
>>> > why would i use a class in php, and how do i use a class in php?
> Simplistic: Classes make it easier to write "reusable" code
>
> For more information about classes in php... read the manual (there areDoes PHP support inheritance and the like?> little examples on how to use them)
> also search google for OO and php or OOPS and php (Object Oriented)
I too never understood the point of classes but due to HAVING to learn about
C# which is entirely OO, I've found them to be VERY usefull. I'll certainly
be porting my new found OOP knowledge to my PHP work.
BTW - my advice to anybody who doesn't know what classes are for; go and
learn now! The concept can be quite difficult to grasp, but once you have,
you'll wish you learnt earlier.
Regards,
Nathan
treefroginometry Guest
-
Phil Roberts #15
Re: classes... why?
With total disregard for any kind of safety measures
"treefroginometry" <info@skunkbag.antispam.co.uk> leapt forth and
uttered:
PHP supports inheritence yes. It's missing a number of structures> Does PHP support inheritance and the like?
>
in PHP4 such as abstract classes, interfaces, private/protected
methods and properties and the like though. These will all be part
of PHP5 however.
It's a state of mind that takes a good while to establish. My> I too never understood the point of classes but due to HAVING to
> learn about C# which is entirely OO, I've found them to be VERY
> usefull. I'll certainly be porting my new found OOP knowledge to
> my PHP work.
>
housemate is a PHP beginner and I had to walk him through the usage
of basic functions as he hadn't even grasped that fundamental
concept. OOP takes it to a whole new level.
Very true.> BTW - my advice to anybody who doesn't know what classes are
> for; go and learn now! The concept can be quite difficult to
> grasp, but once you have, you'll wish you learnt earlier.
--
There is no signature.....
Phil Roberts Guest
-
Phil Roberts #16
Re: classes... why?
With total disregard for any kind of safety measures
"treefroginometry" <info@skunkbag.antispam.co.uk> leapt forth and
uttered:
PHP supports inheritence yes. It's missing a number of structures> Does PHP support inheritance and the like?
>
in PHP4 such as abstract classes, interfaces, private/protected
methods and properties and the like though. These will all be part
of PHP5 however.
It's a state of mind that takes a good while to establish. My> I too never understood the point of classes but due to HAVING to
> learn about C# which is entirely OO, I've found them to be VERY
> usefull. I'll certainly be porting my new found OOP knowledge to
> my PHP work.
>
housemate is a PHP beginner and I had to walk him through the usage
of basic functions as he hadn't even grasped that fundamental
concept. OOP takes it to a whole new level.
Very true.> BTW - my advice to anybody who doesn't know what classes are
> for; go and learn now! The concept can be quite difficult to
> grasp, but once you have, you'll wish you learnt earlier.
--
There is no signature.....
Phil Roberts Guest
-
Default User #17
Re: classes... why?
treefroginometry wrote:
> Does PHP support inheritance and the like?
[url]http://www.php.net/manual/en/language.oop.php[/url]
Brian Rodenborn
Default User Guest
-
Default User #18
Re: classes... why?
treefroginometry wrote:
> Does PHP support inheritance and the like?
[url]http://www.php.net/manual/en/language.oop.php[/url]
Brian Rodenborn
Default User Guest
-
CC Zona #19
Re: classes... why?
In article <Xns93D5EA60A2442philroberts@216.196.97.132>,
Phil Roberts <philrob@HOLYflatnetSHIT.net> wrote:
True. Multiple inheritance is not, however, supported.> With total disregard for any kind of safety measures
> "treefroginometry" <info@skunkbag.antispam.co.uk> leapt forth and
> uttered:
>>> > Does PHP support inheritance and the like?
> >
> PHP supports inheritence yes.
--
CC
CC Zona Guest
-
CC Zona #20
Re: classes... why?
In article <Xns93D5EA60A2442philroberts@216.196.97.132>,
Phil Roberts <philrob@HOLYflatnetSHIT.net> wrote:
True. Multiple inheritance is not, however, supported.> With total disregard for any kind of safety measures
> "treefroginometry" <info@skunkbag.antispam.co.uk> leapt forth and
> uttered:
>>> > Does PHP support inheritance and the like?
> >
> PHP supports inheritence yes.
--
CC
CC Zona Guest



Reply With Quote

