Closed Thread Icon

Preserved Topic: PHP and contexts... (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12332" title="Pages that link to Preserved Topic: PHP and contexts... (Page 1 of 1)" rel="nofollow" >Preserved Topic: PHP and contexts... <span class="small">(Page 1 of 1)</span>\

 
lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 07-24-2002 14:53

i want two different files with almost same functions names and call these same name functions seperatly, how can i do that?

how can i load lib1.php and call funct() and then call funct() from lib2.php in the same script?

any ideas?

when i eval() does it eval in the same context as my script?

thoughts will be appreciated.

//lallous

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 07-24-2002 14:58

The PHP manual tells you that there is not function overloading allowed. This would lead me to believe you would have to change the names of your functions.

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 07-24-2002 16:01

i'm not looking for function overloading though...

I want some sort of a way to allow me to execute a function in a certain context and then destroy that context as if running a script seperatly.



bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 07-24-2002 18:57

put it in a class

class lib1 {
function something() {
}
}

class lib2 {
function something() {
}
}

Then you have 2 ways of dealing with this.

first you can call the functions themselves like so lib1::something(); and lib2::something() or you can create instances of the class something like

or you can create instances of the seperate classes and use them seperately.

$mything = new lib1;
$mything->something();


$mything = new lib2
$mything->something();

I'm working on a project that works with images that I want to work with either imagemagick or gd depending what the environment supports so I'm using the second method with a switch to create objects that have different functions but can be called the same way. something like so:

if ($gd) $myImage = new gd_class;
elseif ($imageMagick) $myImage = new magick_class;

Then either way I can just call

$myImage->createThumb();

and it will create a thumbnail using different functions.




.:[ Never resist a perfect moment ]:.

[This message has been edited by bitdamaged (edited 07-24-2002).]

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 07-25-2002 09:38

thanks all.


« BackwardsOnwards »

Show Forum Drop Down Menu