include() or require() ??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lordrt
Forum Commoner
Posts: 34
Joined: Sun Jul 19, 2009 11:44 pm

include() or require() ??

Post 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)
dave1909
Forum Newbie
Posts: 22
Joined: Sat Jul 25, 2009 8:56 pm

Re: include() or require() ??

Post 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
lordrt
Forum Commoner
Posts: 34
Joined: Sun Jul 19, 2009 11:44 pm

Re: include() or require() ??

Post 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?
dave1909
Forum Newbie
Posts: 22
Joined: Sat Jul 25, 2009 8:56 pm

Re: include() or require() ??

Post 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
lordrt
Forum Commoner
Posts: 34
Joined: Sun Jul 19, 2009 11:44 pm

Re: include() or require() ??

Post by lordrt »

thx for the help
Post Reply