There's a couple points here:
1: echo isn't what you want to do. You want to RETURN the value from you
function. Try this:
<?
function testPassVar($url) {
$name = "TEST";
echo "<a href=\"$url\">Click</a>";
return "<a href=\"$url?name=$name\">Click</a>";
}
$url = 'asdfasdf.php3';
$newURL = testPassVar($url);
echo($newURL);
echo "This is a $name";
?>
2: in the last line, you try to echo $name. $name is defined within the
function testPassVar() and goes out of scope when that function is done At
this point in your script, $name does not exist.
Hope this helps,
Cal
http://www.calevans.com
-----Original Message-----
From: Abe [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 11, 2001 3:35 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Function -> Sending URL's
Hey there,
this is a strange one - I want to send a URL to a function that includes
varibles. Those variables should be taken from within the function - as in
the example below the link I want is:
asdfasdf.php3?name=TEST , but that is not what I get as you can see.
Does anybody know a way around this - The example is simpler than what I am
actually doing and the value of $company must come from the variable.
Thanks,
Abe
<?
function testPassVar($url) {
$name = "TEST";
echo "<a href=\"$url\">Click</a>";
}
$url = 'asdfasdf.php3?name=$company';
testPassVar($url);
echo "This is a $name";
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]