You are here: Re: Is there a more efficient way to do this? « PHP Programming Language « IT news, forums, messages
Re: Is there a more efficient way to do this?

Posted by Jerry Stuckle on 08/16/06 12:26

IchBin wrote:
> Jerry Stuckle wrote:
>
>> Chung Leong wrote:
>>
>>> Rik wrote:
>>>
>>>> --page.php------------
>>>> include('head.html');
>>>> /* generate content */
>>>> include('foot.html');
>>>> ----------------------
>>>
>>>
>>>
>>> Agh! Drives me crazy that people keep recommending this hamfisted
>>> method. Doing includes in lieu of calling function is a poor way to
>>> program. A page header or footer is not different from other
>>> functionalities in your application. To reuse it, wrap it in a
>>> function. Example:
>>>
>>
>> Sorry, Chung, I agree with Rik on this one. This is an excellent way
>> to reuse the code. I use various incarnations of this (either in PHP
>> or using SSI) in a lot of code.
>>
>> It sure is a lot better than trying to keep everything in one page.
>>
>>
> With this thread, for myself, I have some questions of the same. Again I
> am new top PHP. Coming from Java I design and write in OOD\OOP manner.
> And some patterns where I find it applicable.
>
> I am now trying to figure all that out when using php as a scripting
> language how I should do that. My best bet to find that out is to look
> at code already developed, say Pear code or some main stream PHP
> products. The same way I would look at the Java JDK source for tips on
> coding the OOD\OOP way.
>
> Naturally I have seen many introductions to using OOPs with PHP but not
> much OOD. In Java I would segregate my code into the appropriate classes
> in their own files 'class.java'. Also keeping any sub classing of a
> class in the same file. Not sure if I can subclass or have anonymous
> classes in PHP yet.
>
> I was going to do the same with PHP. Should I keep these classes in a
> file as class.php or class.inc? What are the feelings about designing
> PHP code like this. I realize that there is a lot of overhead doing it
> this way but then PHP just started to allow any type of OOP. I am sure
> this will work it's self out as PHP matures to handle OOP. I am just
> having a problems with the 'top-downness' of php as a scripting lang.
>
> --
> Thanks in Advance...
> IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
> 'If there is one, Knowledge is the "Fountain of Youth"'
> -William E. Taylor, Regular Guy (1952-)

Personally, I use a similar setup - each class in its own file, or two
related classes in a file (i.e. for a database table, I might have one
class representing a single row, while another represents a collection
of rows).

I use a convention similar to class.inc.php. You'll need to have the
..php extension; Apache won't parse .inc files unless you change your
httpd.conf (or .htaccess).

There's a little more overhead, but I find it makes things a lot easier
in the long run.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация