RE: [PHP] Changed variabele
| From: | Maxim Maletsky | Date: | Mon, 30 Oct 2000 11:10:11 +0000 |
| Subject: | RE: [PHP] Changed variabele | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-22654@lists.php.net to get a copy of this message | ||
Well, this is something you should play with just like I am playing with it
right now.. (you might be lucky to have found me here awake:-)))
What you need is to write a function that will generate a link for you.
But this is sort of complicated, if there not too many staff you could then
only write it like this:
$This_Page="$SCRIPT_NAME?";
$Get_Vars = $HTTP_GET_VARS;
function LinkGenerator($var, $val)
{
Global Get_Vars;
for(reset($Get_Vars); $key=key($Get_Vars); next($Get_Vars))
{
if($key==$var) Continue;
else $this = $Get_Vars[$key];
$link .= "$key=$this&";
}
return "$link$var=$val";
}
?>
<P>Then you can echo it here:
<P><?=$This_Page.LinkGenerator('link', 'contact')?>
<P><?=$This_Page.LinkGenerator('link', 'home')?>
<P>and this would replace only the 'link' with what you give to him, Try to
write something in your URL..
Hey, I just wrote a whole code for you! And I will use for my own! Thanks
for your question, you make me do the things I was always lazy to.
:-))
The code is not perfect, I will do something to support more then 1 change
in the link. But this is also pretty helpful.
Cheers!
-----Original Message-----
From: Jan van Schaijk [mailto:beethoven@hetnet.nl]
Sent: Monday, October 30, 2000 6:19 PM
To: Maxim Maletsky
Subject: RE: [PHP] Changed variabele
Well,
I made a page index.php3 which contains the links to index.php3?link=home
and ?link=contact.
When I click on them, the $link has been changed so if it reads index.php3
again, I have to look if the $link has been changed. And then I can use the
switch I guess...
But, another problem: if I click on a link at index.php3 (for example
index.php3?language=dutch), all other variables will be empty when it
reloads!
How is that possible?
Jan
-----Oorspronkelijk bericht-----
Van: Maxim Maletsky [mailto:maxim.maletsky@japaninc.net]
Verzonden: maandag 30 oktober 2000 11:13
Aan: 'Jan van Schaijk'; Php-list
Onderwerp: RE: [PHP] Changed variabele
It is Global. The included pages are becoming the part of the script, so you
can use everything available in every text you include.
Ithink the expample you gave would work, but I am not sure I understood
you..
if I want to check whether someone is asking for home link or contact in a
URL like http://site.com/page=contact: then:
if($page=='home')
$link='/index.html';
elseif($page=='contact')
$link='/contact.html';
else
$link='Unknown link, sorry';
would do the simple trick.
Cheers!
-----Original Message-----
From: Jan van Schaijk [mailto:beethoven@hetnet.nl]
Sent: Monday, October 30, 2000 5:39 PM
To: Php-list
Subject: [PHP] Changed variabele
Hi,
I have two questions:
- is a variable like http://.../bla.php3?variabele=1
global?
So, if I use '#include bla2.php3' can I use is in the file bla2.php3 ?
- How can I check if a variable has changed?
I made links in my document like : index.php3?link=home and
index.php3?link=contact
In index.php3 I want to check if a variable has changed, so if a link is
clicked.
Can I do it by this:
if ($link) {
switch ($link)
{
case "home": { echo "<HTML>" }
case "contact": { echo "contact" }
}
$link="";
}
?
Jan van Schaijk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net