Page 1 of 1

include() or require() ??

Posted: Tue Aug 04, 2009 1:11 am
by lordrt
Am calling a php file in another file but am hesitating between include() and require(), which one is most recommended?

I also have to call a function from one file to the other, what is the statement for this???

The function is like: function Function1(param1, param2....paramX)

Re: include() or require() ??

Posted: Tue Aug 04, 2009 1:42 am
by dave1909
if you use require and there is a problem with the file you're calling, the rest of the code will not be executed. its totally up to you which one you use and it depends on how you need to use them.

again with the function, just use require() or include() and you'll be able to use that function anywhere in that page

Re: include() or require() ??

Posted: Tue Aug 04, 2009 1:49 am
by lordrt
dave1909 wrote:if you use require and there is a problem with the file you're calling, the rest of the code will not be executed. its totally up to you which one you use and it depends on how you need to use them.

again with the function, just use require() or include() and you'll be able to use that function anywhere in that page
u knw the code to call the function found in one script to another script?

Re: include() or require() ??

Posted: Tue Aug 04, 2009 1:59 am
by dave1909
as far as i know, by including the file with the function in, you can just use the function as if it were on the same page.

insert
include(functionpage.php);
into your header and
function Function1(param1, param2....paramX)
where you want to call the function

Re: include() or require() ??

Posted: Tue Aug 04, 2009 2:20 am
by lordrt
thx for the help