[thelist] personal PHP preference inquiry
partyarmy
partyarmy at gmail.com
Thu Apr 28 19:36:01 CDT 2005
where did you learn your oop in php, i would like to make the jump,
but have had a hard time approaching the oop style.
On 4/26/05, Jonathan Dillon <jdillon at boehm-ritter.com> wrote:
>
> -----Original Message-----
> From: thelist-bounces at lists.evolt.org
> [mailto:thelist-bounces at lists.evolt.org] On Behalf Of Antonio Angelo
> Sent: Tuesday, April 26, 2005 11:01 AM
> To: Rick den Haan; thelist at lists.evolt.org
> Subject: Re: [thelist] personal PHP preference inquiry
>
> 2005/4/24, Rick den Haan <rick.denhaan at gmail.com>:
> > I was wondering how all you PHP programmers out there work with custom
> > functions. Do you like to:
> >
> > a) put all necessary functions in the page itself;
> > b) put all functions in one seperate file, and include this big file
> > into the page;
> > c) put each function in its own file, and include when needed;
> > d) else?
>
> Abandon all hope, and stop programming in proceedural php. It's VERY easy
> to simply put your code into a class file. I always have a directory called
> /classes in the doc root. If you make a class called example, for example,
> you would do:
>
> /classes/example_class.php (or something similar).
>
> Working with classes is CAKE.
>
> A class looks like this in php4:
>
> <?
> class example {
>
> // sample var
> var $myvar;
>
> // init method (a method is function in a class) for constructor
> function example() {
> // stick my default variable(s) here
> }
>
> function getExample() {
> SQL here...
> }
> }
> ?>
>
> To access this in a page is SO easy...
>
> <?
> include("/classes/example_class.php");
> $example = new example;
>
> echo $example->myvar;
> ?>
>
> Sorry, I thought I should take the opportunity to throw out some OO php.
> I've been working with it now for the last few years, and it's fantastically
> easier.
>
> J
>
> --
>
> * * Please support the community that supports you. * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>
More information about the thelist
mailing list