Is all the code into a function automatically read before I call that function?

Discussion in 'PHP' started by AKnogood, Aug 27, 2009.

  1. #1
    At the top of my index.php I have an include ("./functions.php"); which contains all the functions that I might use later in my code.

    I know the code in each function is not "started" until the specific function is called later but is all this code still automatically read each time index.php is called? If so I guess having too big of a file could really slow my site?
     
    AKnogood, Aug 27, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yes, all that code is read. I suppose if you have a heck of alot in there, it could slow down your site a tiny bit.. Just use an opcode cache like APC if you are worried about that, or do some real testing with xdebug instead of making assumptions. Premature optimization is the root of all evil ;)
     
    premiumscripts, Aug 27, 2009 IP
  3. AKnogood

    AKnogood Active Member

    Messages:
    244
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Thanks for the answer.

    I'll try xdebug.
     
    AKnogood, Aug 27, 2009 IP