Re: [PHP] calling functions from one or multiple files

2008-09-26 Thread Ashley Sheridan
On Thu, 2008-09-25 at 23:02 -0400, Robert Cummings wrote:
 On Fri, 2008-09-26 at 02:10 +0200, Jochem Maas wrote:
  Ashley Sheridan schreef:
   On Fri, 2008-09-26 at 01:05 +0200, Jochem Maas wrote:
   tedd schreef:
   At 3:44 PM -0400 9/24/08, Robert Cummings wrote:
   Seems kind of silly to have every function in it's own file. Also seems
   kind of cluttered ot have every function in one file.
  
   Now grouping related functions into a single file... that's sounds like
   a good middle ground.
  
   Cheers,
   Rob.
   The Goldie Locks solution.
   otherwise known as mediorce ... rather like his blowup doll :-P
  
   Cheers,
  
   tedd
  
   Why does it always come back to that poor doll?!
  
  dunno, but it's rather apt to say 'screw the doll' :-P
 
 Hmm. I tried:
 
  apt-get screw the doll
 E: Invalid operation screw
 
 What am I doing wrong?
 
 Cheers,
 Rob.
 -- 
 http://www.interjinn.com
 Application and Templating Framework for PHP
 
 
This happens if you use the wrong parameters. Use a LONG instead of a
SHORT ;)


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] calling functions from one or multiple files

2008-09-25 Thread tedd

At 3:44 PM -0400 9/24/08, Robert Cummings wrote:

Seems kind of silly to have every function in it's own file. Also seems
kind of cluttered ot have every function in one file.

Now grouping related functions into a single file... that's sounds like
a good middle ground.

Cheers,
Rob.


The Goldie Locks solution.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] calling functions from one or multiple files

2008-09-25 Thread Jochem Maas
tedd schreef:
 At 3:44 PM -0400 9/24/08, Robert Cummings wrote:
 Seems kind of silly to have every function in it's own file. Also seems
 kind of cluttered ot have every function in one file.

 Now grouping related functions into a single file... that's sounds like
 a good middle ground.

 Cheers,
 Rob.
 
 The Goldie Locks solution.

otherwise known as mediorce ... rather like his blowup doll :-P

 
 Cheers,
 
 tedd


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] calling functions from one or multiple files

2008-09-25 Thread Ashley Sheridan
On Fri, 2008-09-26 at 01:05 +0200, Jochem Maas wrote:
 tedd schreef:
  At 3:44 PM -0400 9/24/08, Robert Cummings wrote:
  Seems kind of silly to have every function in it's own file. Also seems
  kind of cluttered ot have every function in one file.
 
  Now grouping related functions into a single file... that's sounds like
  a good middle ground.
 
  Cheers,
  Rob.
  
  The Goldie Locks solution.
 
 otherwise known as mediorce ... rather like his blowup doll :-P
 
  
  Cheers,
  
  tedd
 
 
Why does it always come back to that poor doll?!


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] calling functions from one or multiple files

2008-09-25 Thread Jochem Maas
Ashley Sheridan schreef:
 On Fri, 2008-09-26 at 01:05 +0200, Jochem Maas wrote:
 tedd schreef:
 At 3:44 PM -0400 9/24/08, Robert Cummings wrote:
 Seems kind of silly to have every function in it's own file. Also seems
 kind of cluttered ot have every function in one file.

 Now grouping related functions into a single file... that's sounds like
 a good middle ground.

 Cheers,
 Rob.
 The Goldie Locks solution.
 otherwise known as mediorce ... rather like his blowup doll :-P

 Cheers,

 tedd

 Why does it always come back to that poor doll?!

dunno, but it's rather apt to say 'screw the doll' :-P

 
 
 Ash
 www.ashleysheridan.co.uk
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] calling functions from one or multiple files

2008-09-25 Thread Robert Cummings
On Fri, 2008-09-26 at 01:05 +0200, Jochem Maas wrote:
 tedd schreef:
  At 3:44 PM -0400 9/24/08, Robert Cummings wrote:
  Seems kind of silly to have every function in it's own file. Also seems
  kind of cluttered ot have every function in one file.
 
  Now grouping related functions into a single file... that's sounds like
  a good middle ground.
 
  Cheers,
  Rob.
  
  The Goldie Locks solution.
 
 otherwise known as mediorce ... rather like his blowup doll :-P

What's mediorce? Is that like an orc that's not too large, but not too
small?

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] calling functions from one or multiple files

2008-09-25 Thread Robert Cummings
On Fri, 2008-09-26 at 02:10 +0200, Jochem Maas wrote:
 Ashley Sheridan schreef:
  On Fri, 2008-09-26 at 01:05 +0200, Jochem Maas wrote:
  tedd schreef:
  At 3:44 PM -0400 9/24/08, Robert Cummings wrote:
  Seems kind of silly to have every function in it's own file. Also seems
  kind of cluttered ot have every function in one file.
 
  Now grouping related functions into a single file... that's sounds like
  a good middle ground.
 
  Cheers,
  Rob.
  The Goldie Locks solution.
  otherwise known as mediorce ... rather like his blowup doll :-P
 
  Cheers,
 
  tedd
 
  Why does it always come back to that poor doll?!
 
 dunno, but it's rather apt to say 'screw the doll' :-P

Hmm. I tried:

 apt-get screw the doll
E: Invalid operation screw

What am I doing wrong?

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] calling functions from one or multiple files

2008-09-24 Thread b

Lamp Lists wrote:

Hi,
Right now I use one file, usually called functions.php, with all functions I'm 
going to use most likely on every page.
Then, I create each function I'm going to use once in a while as separate file.
Pro: I would include a function when I'm going to use.
Con: I have to write extra include line to call function. And have bunch of 
files (functions) in function folder.

I was talking to co-workers few days ago and they said I complicate my
life to much and putting ALL functions in one file is just fine and
I'll not be able to see difference in real situations.



When not using a framework (eg. Cake) i also usually keep a single file 
and include it. I think it depends on how many functions you have. If 
you've got a really huge functions.php and most of them are used only in 
one or two scripts, then you probably shouldn't be loading it into every 
script. Otherwise, i wouldn't be too concerned about it.


Of course, you should also think about using classes if that makes sense 
for what you're doing.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] calling functions from one or multiple files

2008-09-24 Thread Ashley Sheridan
On Wed, 2008-09-24 at 12:37 -0400, b wrote:
 Lamp Lists wrote:
  Hi,
  Right now I use one file, usually called functions.php, with all functions 
  I'm going to use most likely on every page.
  Then, I create each function I'm going to use once in a while as separate 
  file.
  Pro: I would include a function when I'm going to use.
  Con: I have to write extra include line to call function. And have bunch of 
  files (functions) in function folder.
  
  I was talking to co-workers few days ago and they said I complicate my
  life to much and putting ALL functions in one file is just fine and
  I'll not be able to see difference in real situations.
  
 
 When not using a framework (eg. Cake) i also usually keep a single file 
 and include it. I think it depends on how many functions you have. If 
 you've got a really huge functions.php and most of them are used only in 
 one or two scripts, then you probably shouldn't be loading it into every 
 script. Otherwise, i wouldn't be too concerned about it.
 
 Of course, you should also think about using classes if that makes sense 
 for what you're doing.
 
I tend to try and group functions I use on a site, with common ones
going into a generic functions.php file. This avoid the problems of
overly large function files included on every page, as chances are you
won't need every function.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] calling functions from one or multiple files

2008-09-24 Thread b

Ashley Sheridan wrote:

On Wed, 2008-09-24 at 12:37 -0400, b wrote:

Lamp Lists wrote:

Hi, Right now I use one file, usually called functions.php, with
all functions I'm going to use most likely on every page. Then, I
create each function I'm going to use once in a while as separate
file. Pro: I would include a function when I'm going to use. Con:
I have to write extra include line to call function. And have
bunch of files (functions) in function folder.

I was talking to co-workers few days ago and they said I
complicate my life to much and putting ALL functions in one file
is just fine and I'll not be able to see difference in real
situations.


When not using a framework (eg. Cake) i also usually keep a single
file and include it. I think it depends on how many functions you
have. If you've got a really huge functions.php and most of them
are used only in one or two scripts, then you probably shouldn't be
loading it into every script. Otherwise, i wouldn't be too
concerned about it.

Of course, you should also think about using classes if that makes
sense for what you're doing.

I tend to try and group functions I use on a site, with common ones 
going into a generic functions.php file. This avoid the problems of 
overly large function files included on every page, as chances are

you won't need every function.



Done that, but not so much anymore. It depends on how specialised the 
functions (and sections) are. Usually an administration section can do 
with a separate file (while also including the general one). But, for 
other areas, it'll work fine until you find that you need a function 
that's in another file.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] calling functions from one or multiple files

2008-09-24 Thread Eric Butera
On Wed, Sep 24, 2008 at 12:28 PM, Lamp Lists [EMAIL PROTECTED] wrote:
 Hi,
 Right now I use one file, usually called functions.php, with all functions 
 I'm going to use most likely on every page.
 Then, I create each function I'm going to use once in a while as separate 
 file.
 Pro: I would include a function when I'm going to use.
 Con: I have to write extra include line to call function. And have bunch of 
 files (functions) in function folder.

 I was talking to co-workers few days ago and they said I complicate my
 life to much and putting ALL functions in one file is just fine and
 I'll not be able to see difference in real situations.

 True?

 -ll





I work with functions much the same way that I work with classes.
When I'm forced to work on procedural code I always prefix the
namespace onto it.  Let's take a very generic shopping cart example.
There's going to be products and a cart.

Here are the files/prototypes:

/code/storeappname/item.php
function storeappname_item_load(int $id);
function storeappname_item_save(array $item);
function storeappname_item_delete(int $id);

/code/storeappname/cart.php
function storeappname_cart_add_item(array $item);
function storeappname_cart_remove_item(int $id);
function storeappname_cart_calculate_totals();

I'd set /code into the include path.  Depending on what page you're on
you just include the function files that you know you're going to use
like require_once 'storeappname/cart.php', etc.  Too bad there's not
an autoload for functions.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] calling functions from one or multiple files

2008-09-24 Thread Thodoris



On Wed, 2008-09-24 at 12:37 -0400, b wrote:
  

Lamp Lists wrote:


Hi,
Right now I use one file, usually called functions.php, with all functions I'm 
going to use most likely on every page.
Then, I create each function I'm going to use once in a while as separate file.
Pro: I would include a function when I'm going to use.
Con: I have to write extra include line to call function. And have bunch of 
files (functions) in function folder.

I was talking to co-workers few days ago and they said I complicate my
life to much and putting ALL functions in one file is just fine and
I'll not be able to see difference in real situations.

  
When not using a framework (eg. Cake) i also usually keep a single file 
and include it. I think it depends on how many functions you have. If 
you've got a really huge functions.php and most of them are used only in 
one or two scripts, then you probably shouldn't be loading it into every 
script. Otherwise, i wouldn't be too concerned about it.


Of course, you should also think about using classes if that makes sense 
for what you're doing.




I tend to try and group functions I use on a site, with common ones
going into a generic functions.php file. This avoid the problems of
overly large function files included on every page, as chances are you
won't need every function.


Ash
www.ashleysheridan.co.uk


  
I was using the same method until now but functions.php grew so much 
that made my life difficult. The solution was to break down this file 
into smaller files that each included a category like:

web.php
db.php
math.php
client.php
user.php
session.php
etc.

This made my life easier since I can edit and maintain the separate 
files more efficiently and I didn't have to include the whole API every 
time but only the files I really need. A good thing was to put these 
files into a separate dir which I named include.


Same thing applies to classes I guess which is probably the next step.


Thodoris


Re: [PHP] calling functions from one or multiple files

2008-09-24 Thread Ashley Sheridan
On Wed, 2008-09-24 at 20:32 +0300, Thodoris wrote:
 
  On Wed, 2008-09-24 at 12:37 -0400, b wrote:

   Lamp Lists wrote:
   
Hi,
Right now I use one file, usually called functions.php, with all 
functions I'm going to use most likely on every page.
Then, I create each function I'm going to use once in a while as 
separate file.
Pro: I would include a function when I'm going to use.
Con: I have to write extra include line to call function. And have 
bunch of files (functions) in function folder.

I was talking to co-workers few days ago and they said I complicate my
life to much and putting ALL functions in one file is just fine and
I'll not be able to see difference in real situations.

  
   When not using a framework (eg. Cake) i also usually keep a single file 
   and include it. I think it depends on how many functions you have. If 
   you've got a really huge functions.php and most of them are used only in 
   one or two scripts, then you probably shouldn't be loading it into every 
   script. Otherwise, i wouldn't be too concerned about it.
   
   Of course, you should also think about using classes if that makes sense 
   for what you're doing.
   
   
  I tend to try and group functions I use on a site, with common ones
  going into a generic functions.php file. This avoid the problems of
  overly large function files included on every page, as chances are you
  won't need every function.
  
  
  Ash
  www.ashleysheridan.co.uk
  
  

 I was using the same method until now but functions.php grew so much
 that made my life difficult. The solution was to break down this file
 into smaller files that each included a category like:
 web.php
 db.php
 math.php
 client.php
 user.php
 session.php
 etc.
 
 This made my life easier since I can edit and maintain the separate
 files more efficiently and I didn't have to include the whole API
 every time but only the files I really need. A good thing was to put
 these files into a separate dir which I named include.
 
 Same thing applies to classes I guess which is probably the next step.
 
 
 Thodoris
Ah maybe I wasn't clear but that's what I meant by grouping the
functions. Generic ones that are used on all pages go into functions.php
and others go into other function includes. So I might have one that
deals with my blog, other for images, etc, depending on the project in
question.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] calling functions from one or multiple files

2008-09-24 Thread Richard Lynch
 -Original Message-
 Right now I use one file, usually called functions.php, with all
 functions I'm going to use most likely on every page.
 Then, I create each function I'm going to use once in a while as
 separate file.
 Pro: I would include a function when I'm going to use.
 Con: I have to write extra include line to call function. And have
 bunch of files (functions) in function folder.

 I was talking to co-workers few days ago and they said I complicate my
 life to much and putting ALL functions in one file is just fine and
 I'll not be able to see difference in real situations.

You'd have to have a LOT of functions either way to make a difference...

Actually, it's probably more expensive to open up the individual function files 
than to toss ~30 more functions into a single file.

You'll have to profile 'require' on your own hardware to turn ~30 into a real 
number...


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] calling functions from one or multiple files

2008-09-24 Thread Robert Cummings
On Wed, 2008-09-24 at 13:58 -0500, Richard Lynch wrote:
  -Original Message-
  Right now I use one file, usually called functions.php, with all
  functions I'm going to use most likely on every page.
  Then, I create each function I'm going to use once in a while as
  separate file.
  Pro: I would include a function when I'm going to use.
  Con: I have to write extra include line to call function. And have
  bunch of files (functions) in function folder.
 
  I was talking to co-workers few days ago and they said I complicate my
  life to much and putting ALL functions in one file is just fine and
  I'll not be able to see difference in real situations.
 
 You'd have to have a LOT of functions either way to make a difference...
 
 Actually, it's probably more expensive to open up the individual function 
 files than to toss ~30 more functions into a single file.
 
 You'll have to profile 'require' on your own hardware to turn ~30 into a real 
 number...

Seems kind of silly to have every function in it's own file. Also seems
kind of cluttered ot have every function in one file.

Now grouping related functions into a single file... that's sounds like
a good middle ground.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php