Re: [PHP] Is there a way to un include a file

2007-03-12 Thread Richard Lynch
No.

You could perhaps wipe out *EVERYTHING* in $_GLOBALS, which would be
the included file and anything in the main file[s] that went before.

If you need an environment that is that "pure" for testing or
something, you can run a different PHP process on each file.

Otherwise, you simply have to architect your application correctly.

Some other solutions to this naming/scope problem include 'packages'
which php doesn't have and 'namespaces' which php doesn't have and...

There have been innumerable flame wars here and on Internals about the
right way to add a new feature to do this, and I don't think there is
any real concensus yet.

On Thu, March 8, 2007 1:18 am, jekillen wrote:
> Hello;
> Is there a way to un include a file once it has been included in a
> script.
> My concern is where two php files might be included in another php
> file they might have code or variables that conflict. I am thinking
> of including files with different names but follow the same pattern
> of code and variables but may have different values for variables
> or different versions of the same function.
> If there is not a specific function for un including a file (I have
> not
> seen any indication from my text books that there is), it seems like
> it would be nice to have one.
> Meanwhile I will be doing some experimentation.
> Thanks in advance;
> Jeff K
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Is there a way to un include a file

2007-03-08 Thread Chris

jekillen wrote:


On Mar 7, 2007, at 11:47 PM, Larry Garfield wrote:


No there is not, because an included file *executes* at the time it is
included and is then done.  Any memory-resident objects (function/class
definitions, variables, etc.) that it defies then exist until you make 
them
un-exist (with unset() for variables or, well, you can't with 
functions and

classes AFAIK).

Include files are libraries.  They are not functions.  What you're 
looking for
is a function.  Don't try to use include files as functions.  Therein 
lies

pain.


I have function definitions in included files all over the place. I do that
so one file will not be too big to keep scrolling back and forth through
to develop and debug. These are mainly in conjunction with multi
phase self processing forms.
Variables I could guess would be overwritten,
but if I have a function fu defined in two different files that are include
in, say, a loop and I want to call one function fu on one iteration from
one included file, then the next iteration I include the next file and
call fu that is a different version, which function would be executed on
the second iteration?


You can't have two functions with the same name for exactly this reason.

$ php -a
Interactive mode enabled

Fatal error: Cannot redeclare a() (previously declared in -:2) in - on 
line 3


So when script '2' is included (ie the 2nd loop), it's going to throw 
this sort of error.



Time to rethink your design.

--
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP] Is there a way to un include a file

2007-03-08 Thread jekillen


On Mar 7, 2007, at 11:47 PM, Larry Garfield wrote:


No there is not, because an included file *executes* at the time it is
included and is then done.  Any memory-resident objects (function/class
definitions, variables, etc.) that it defies then exist until you make 
them
un-exist (with unset() for variables or, well, you can't with 
functions and

classes AFAIK).

Include files are libraries.  They are not functions.  What you're 
looking for
is a function.  Don't try to use include files as functions.  Therein 
lies

pain.


I have function definitions in included files all over the place. I do 
that

so one file will not be too big to keep scrolling back and forth through
to develop and debug. These are mainly in conjunction with multi
phase self processing forms.
Variables I could guess would be overwritten,
but if I have a function fu defined in two different files that are 
include

in, say, a loop and I want to call one function fu on one iteration from
one included file, then the next iteration I include the next file and
call fu that is a different version, which function would be executed on
the second iteration?

Thanks for the response, I think I will have to do some experimentation
with this one.
Jeff K

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



Re: [PHP] Is there a way to un include a file

2007-03-07 Thread Larry Garfield
No there is not, because an included file *executes* at the time it is 
included and is then done.  Any memory-resident objects (function/class 
definitions, variables, etc.) that it defies then exist until you make them 
un-exist (with unset() for variables or, well, you can't with functions and 
classes AFAIK).  

Include files are libraries.  They are not functions.  What you're looking for 
is a function.  Don't try to use include files as functions.  Therein lies 
pain.  

On Thursday 08 March 2007 12:18 am, jekillen wrote:
> Hello;
> Is there a way to un include a file once it has been included in a
> script.
> My concern is where two php files might be included in another php
> file they might have code or variables that conflict. I am thinking
> of including files with different names but follow the same pattern
> of code and variables but may have different values for variables
> or different versions of the same function.
> If there is not a specific function for un including a file (I have not
> seen any indication from my text books that there is), it seems like
> it would be nice to have one.
> Meanwhile I will be doing some experimentation.
> Thanks in advance;
> Jeff K

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

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



Re: [PHP] Is there a way to un include a file

2007-03-07 Thread Tijnema !

AFAIK there's no function to un include a file, but i don't see a problem
here, as when you include your second file, everything (all conflicting
variables) will be overwritten.
If you still have problems, you might want to use classes around your
functions and variables.

Tijnema


On 3/8/07, jekillen <[EMAIL PROTECTED]> wrote:


Hello;
Is there a way to un include a file once it has been included in a
script.
My concern is where two php files might be included in another php
file they might have code or variables that conflict. I am thinking
of including files with different names but follow the same pattern
of code and variables but may have different values for variables
or different versions of the same function.
If there is not a specific function for un including a file (I have not
seen any indication from my text books that there is), it seems like
it would be nice to have one.
Meanwhile I will be doing some experimentation.
Thanks in advance;
Jeff K

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




Re: [PHP] Is there a way to un include a file

2007-03-07 Thread Børge Holen
On Thursday 08 March 2007 07:18, jekillen wrote:
> Hello;
> Is there a way to un include a file once it has been included in a
> script.

You seems to want the wrong thing... 

I could be mistaken, but from my point of view you would NOT include the file 
if not apropriate at that moment. 


> My concern is where two php files might be included in another php
> file they might have code or variables that conflict. I am thinking
> of including files with different names but follow the same pattern
> of code and variables but may have different values for variables
> or different versions of the same function.
> If there is not a specific function for un including a file (I have not
> seen any indication from my text books that there is), it seems like
> it would be nice to have one.
> Meanwhile I will be doing some experimentation.
> Thanks in advance;
> Jeff K

-- 
---
Børge
Kennel Arivene 
http://www.arivene.net
---

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



[PHP] Is there a way to un include a file

2007-03-07 Thread jekillen

Hello;
Is there a way to un include a file once it has been included in a 
script.

My concern is where two php files might be included in another php
file they might have code or variables that conflict. I am thinking
of including files with different names but follow the same pattern
of code and variables but may have different values for variables
or different versions of the same function.
If there is not a specific function for un including a file (I have not
seen any indication from my text books that there is), it seems like
it would be nice to have one.
Meanwhile I will be doing some experimentation.
Thanks in advance;
Jeff K

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