RE: [PHP] require or include ?

2002-03-28 Thread Rick Emery

require() is used when you want the file included regardless of whether any
information is used from it.  include() may be conditional.

-Original Message-
From: javier [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 28, 2002 4:44 PM
To: [EMAIL PROTECTED]
Subject: [PHP] require or include ?


When should I use require or include?
I read that include copies the content from the file to the script that
is calling it.
And require is like #include in C.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] require or include ?

2002-03-28 Thread Javier


If I include for ex. common.php in a script and this script also calls
common.php what should I use require or include?


On Thu, Mar 28, 2002 at 04:44:04PM -0600, Rick Emery wrote:
 require() is used when you want the file included regardless of whether any
 information is used from it.  include() may be conditional.
 
 -Original Message-
 From: javier [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, March 28, 2002 4:44 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] require or include ?
 
 
 When should I use require or include?
 I read that include copies the content from the file to the script that
 is calling it.
 And require is like #include in C.
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] require or include ?

2002-03-28 Thread bvr


both include the file, but
use require() when it is required, and include() when it's not.

In the new behaviour these two make no further difference.

bvr.

Javier wrote:

If I include for ex. common.php in a script and this script also calls
common.php what should I use require or include?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] require() vs include()

2002-03-15 Thread Ford, Mike [LSS]

 -Original Message-
 From: Jim Lucas [php] [mailto:[EMAIL PROTECTED]]
 Sent: 15 March 2002 00:55
 
 Plus, depending on how you are calling the file.  Meaning if 
 the file name
 that you are calling is a static file name or dynamic file name
 
 require() and require_once()  will include a file before the 
 php parser
 starts its job, but this will only happen if the name isn't dynamic.

In fact, I believe that what you are describing is an OLD behaviour (prior to PHP 
4.0.2, in fact).  However, the manual has only recently changed to document the new 
behaviour (and actually doesn't do it very well, yet).  Now, BOTH require and include 
(and their _once versions) work dynamically, and the only difference is in how they 
report a failure.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] require() vs include()

2002-03-14 Thread SHEETS,JASON (Non-HP-Boise,ex1)

They are much the same, both include a file.

To quote the PHP manual require() and include() are identical in every way
except how they handle failure. include() produces a Warning while require()
results in a Fatal Error. In other words, don't hesitate to use require() if
you want a missing file to halt processing of the page. include() does not
behave this way, the script will continue regardless. Be sure to have an
appropriate include_path setting as well.

That said I would use require_once and include_once instead of just include
and require, these functions ensure the file is only included once which
prevents a lot of problems.

Jason

-Original Message-
From: David McInnis [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 14, 2002 4:47 PM
To: [EMAIL PROTECTED]
Subject: [PHP] require() vs include()


Are these redundant functions or are they different?  I seem to be able
to use the interchangeably.

David McInnis



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] require() vs include()

2002-03-14 Thread Jim Lucas [php]

Plus, depending on how you are calling the file.  Meaning if the file name
that you are calling is a static file name or dynamic file name

require() and require_once()  will include a file before the php parser
starts its job, but this will only happen if the name isn't dynamic.

meaning that if you have this

require(myfile.inc);  //static
and
require($var. .inc); //dynamic

the first one will be included into the before parsing and the second will
wait until the parser comes along and defines the $var value.

if you call require()  or require_once() with a variable in the file handler
name space, it will downgrade (in a way) to just working like an include()
or include_once()

with include() or include_once() it doesn't matter if the file handle name
has a variable in it.  it will always include the file after the parser
starts its job.

Jim Lucas
www.bend.com

- Original Message -
From: SHEETS,JASON (Non-HP-Boise,ex1) [EMAIL PROTECTED]
To: 'David McInnis' [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, March 14, 2002 3:56 PM
Subject: RE: [PHP] require() vs include()


 They are much the same, both include a file.

 To quote the PHP manual require() and include() are identical in every
way
 except how they handle failure. include() produces a Warning while
require()
 results in a Fatal Error. In other words, don't hesitate to use require()
if
 you want a missing file to halt processing of the page. include() does not
 behave this way, the script will continue regardless. Be sure to have an
 appropriate include_path setting as well.

 That said I would use require_once and include_once instead of just
include
 and require, these functions ensure the file is only included once which
 prevents a lot of problems.

 Jason

 -Original Message-
 From: David McInnis [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, March 14, 2002 4:47 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] require() vs include()


 Are these redundant functions or are they different?  I seem to be able
 to use the interchangeably.

 David McInnis



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] require or include

2001-11-15 Thread Mike Eheler

It all depends on the purpose.

With require, the script will die on the spot if the file is not found. 
Also, the code will always be included in the file.. so take this example:

file.php:
?
echo Hello World!;
?

requiretest.php:
?
if (FALSE) {
require('file.php');
}
?

The run script would be:

?
if (FALSE) {
echo Hello World!;
}
?

Of course that code would never be executed, but the required file would 
be parsed and included as part of the file, whereas:

includetest.php:
?
if (FALSE) {
include('file.php');
}
?

If the if() condition is not met, the file is not included at all.. so 
the parsed code would be:

?
if (FALSE) {
}
?

:)

Mike

Oosten, Sjoerd van wrote:

Hello list,

I'm just wandering what's better, require or include.

Greetings,


Sjoerd van Oosten 
Digitaal vormgever [EMAIL PROTECTED]
Datamex E-sites B.V. 
http://www.esites.nl
Minervum 7368 Telefoon: (076) 5 730 730 
4817 ZH BREDA Telefax: (076) 5 877 757 
___





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Require vs include

2001-03-17 Thread Boaz Yahav


Hi

Check out : 

http://www.weberdev.com/index.php3?GoTo=get_example.php3?count=22

Sincerely

  berber

Visit http://www.weberdev.com Today!!! 
To see where PHP might take you tomorrow.
 



-Original Message-
From: NGUYEN DINH Quoc Huy [mailto:[EMAIL PROTECTED]]
Sent: Saturday, March 17, 2001 9:44 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Require vs include


Hi

Can someone explain me what's the difference between include() and require()
??
I did not catch the explanation in the docs.
When should I use include() and when should I use require() ??

I'm not on the list so reply me to: [EMAIL PROTECTED]

Thnx

-- 
=
 NGUYEN DINH Quoc Huy (SnAKes)
   http://www.snakesbox.com/
  [EMAIL PROTECTED] - ICQ# 3398187
  telnet://snakesbox.com:/  -- Puissance 4
=



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]