-1

So hey guys I'm trying to figure the difference between these two.

include('inc/config.php');

with

include_once 'inc/config';

I try google the question above on Google but nothing direct me. So hope you guys can help me to explain. Thanks .

  • 3
    Well, there's a difference between `include` and `include_once`, but the PHP manual explains them both pretty well. – Patrick Q Mar 20 '18 at 13:12
  • @panther thank you for responding. Yeah I miss to close back the single quote there. Thanks. Thanks again. Can you also please share me a link to the manual if you don't mind ? – farhan najmi Mar 20 '18 at 13:16
  • @PatrickQ oh there is ? Please link me to the manual PHP. Thanks – farhan najmi Mar 20 '18 at 13:17
  • @farhannajmi: sorry, the difference between `include` and `include_once` is, of course. I though you have two includes, one with `()`, second without. `include_once` is slower than `include`, but when you need to include just once, there is no other choice (eg. when you define functions in included file, etc.). Then you probably need `require_once` instead of `include[_once]`. – pavel Mar 20 '18 at 13:20
  • http://php.net/manual/es/function.include-once.php and http://php.net/manual/pl/function.include.php from php.net but if you care for a more *stackoverflowy* explanation https://stackoverflow.com/questions/3546160/include-include-once-require-or-require-once will be very helpful – Scaramouche Mar 20 '18 at 13:26

1 Answers1

-1

There is one difference between include() and include_once(). If the code from a file has been already included then it will not be included again if we use include_once(). It means that include_once() include the file only once at a time.

Here is another answer see here

But, You are asking very basic question. You have to analyse the question and do some research about it. You should read this before asking question How to ask questions?

Chirag Patel
  • 1,545
  • 2
  • 9
  • 17