JavaSprout
Programmer
I'm a newbie to this PHP, so this question I'm sure will be a very easy one for you!
I am trying to write a class which can be used in multiple places, for example within abc.php and xyz.php. I want within the class to have a reference to the file which it gets include within, i.e. to abc or to xyz. Of course, at class writing time, I do not know what the name of the file including it is going to be. Therefore I need something like $this, but $this refers to the class.
abc.php is:
include("link_bot.php"
link_bot->show_link(1); // I want link abc.php?key=1
xyz.php is:
include("link_bot.php"
link_bot->show_link(1); // I want link xyz.php?key=1
link_bot.php is:
<?
class link_bot
{
function show_link( $key )
{
// Notice the hard coding of the name 'xyz'
print("<a href=xyz?key=$key>page $key</a>"
}
}
?>
Thanks for any help!
I am trying to write a class which can be used in multiple places, for example within abc.php and xyz.php. I want within the class to have a reference to the file which it gets include within, i.e. to abc or to xyz. Of course, at class writing time, I do not know what the name of the file including it is going to be. Therefore I need something like $this, but $this refers to the class.
abc.php is:
include("link_bot.php"
link_bot->show_link(1); // I want link abc.php?key=1
xyz.php is:
include("link_bot.php"
link_bot->show_link(1); // I want link xyz.php?key=1
link_bot.php is:
<?
class link_bot
{
function show_link( $key )
{
// Notice the hard coding of the name 'xyz'
print("<a href=xyz?key=$key>page $key</a>"
}
}
?>
Thanks for any help!