Posted by Richard on 02/16/07 13:00
I am new to php and am looking for some quick "get up and go" help.
What would the arguments for and against be for function declarations v
simple include?
e.g
<?php
include("myfunc.php"); // declares a function "myfunc".
myfunc("hello");
?>
and
<?php
include("myfunc.php"); // just a bunch of php code with no function
?>
Does PHP cache the functions? Must functions be included on all pages
which use them? The plethora of web resources makes some of this a
trifle confusing and difficult/time consuming to pin down, so any best
practice pointers much appreciated.
Would you keep functions & includes seperate from the main pages? is it
then necessary to specify a fully qualified name when including them or
should one just set the include_path in a header? Can the include path
just be set once for a single session? or in every file which references
includes? Can you recommend a web resource which covers this type of stuff?
[Back to original message]
|