require and include

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
hi everybody!

can someone tell me

- why not require() should not be different from include() -- if they
were diiferent we could opt for one over the other

- why not if in the future we could have a __include php callback
(analogous to the __autoload) that allows developers a last word from
where to include some .php file

- where can i put this feature request to the php core devs?

thanks in advance
regards to all

Re: require and include

Quoted text here. Click to load it
This makes no sense whatsoever!!!!

Care to try again?

Re: require and include

ptdorf escribió:
Quoted text here. Click to load it

English as second language or whisky for breakfast?

- Require() and include() do different things, as stated in the manual.
Whatever your opinion is, that's not likely to change ever.

- PHP offers lots of ways to include external files. If you are missing
one more, you probably have an application design that needs some severe

- The ability to find the bug tracker link in the PHP web site is a
necessary pre-requisite to be allowed to post a feature request. If we
helped you in that it'd be like cheating.

-- - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:
-- Mi web de humor al baño María:

Re: require and include

Quoted text here. Click to load it

I must admit I was surprised when I realised that if include fails it does
not generate a fatal error. This being so, ISTM that almost all the scripts
I see floating around which use "include" should really be using "require"
since they would not work (or worse, are cases of "who knows what they
would do") if any included components were missing. Most people seem to use
include to modularise their source code but ISTM that it is not suited to
that purpose for the above reasons.

Re: require and include

Quoted text here. Click to load it

They are different - RTFM

Quoted text here. Click to load it

That's what the include path is for - and you could easily write your
own - except for the bit about triggering it when it comes across an
undefined literal. The latter bit is a can of worms with procedural
code where there is no clear distinction between user-defined
functions, ore functions and extension functions. I have no idea what
problem you are trying to solve but this doesn't seem the right way to
go about it. If you really must, there's nothing to stop you
encapsulating all your functions in a class, including it using
autoload and calling the methods statically.

Quoted text here. Click to load it

If you can't answer that yourself, then you're going to have trouble
getting them to listen to a sensible suggestion, let alone this one.


Site Timeline