(un)require file

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
nre
Forum Newbie
Posts: 1
Joined: Thu Jun 19, 2003 3:35 am

(un)require file

Post by nre »

I have 3 files:

//---file1.php----
function func1() {
echo "1";
}

//---file2.php----
function func1() { //the func name is the same like func name in file1.php
echo "2";
}

//---file3.php----
require "file1.php";
func1(); //it will write '1'

now I want to require "file2.php" and when the code again reaches to the func1(), it have to write '2'

so is there any unrequire function to remove file1.php include?
or some method for dynamic function deleting?

thx.
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

Some function overloading, ha :?: I don't think you can do that in PHP4, and the same with unrequire. Can you just write one function which will distinguish by func_get_args() or func_num_args() what version to use :?:
Post Reply