/    Sign up×
Community /Pin to ProfileBookmark

print code depending on what location

hi all, i include the header on all of my pages which has the nav menu in it.

is there a php code whitch will print one this if is on a certian page?

i have tried soething like this but doesnt seam to work-

[code=php]
<?php

if($_GET[‘location: index.php’]){
print “home”;
}
else
{
print “go to home”;
}
?>

[/code]

i will write the same thing for each of the 5 main links

Thanks

Sheldon

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@ScleppelJun 01.2005 — Like [URL=http://alistapart.com/articles/keepingcurrent/]this[/URL] from A List Apart?
Copy linkTweet thisAlerts:
@ZiplineJun 01.2005 — Hey Sheldon... you could try something like this...

[code=php]
if($_SERVER['SCRIPT_NAME'] == "index.php") {

include("header.php");

} else {

include("header2.php");

}
[/code]

Or if the headers are very close and you just need to switch out a link you could just wrap this code around that link etc.
Copy linkTweet thisAlerts:
@bokehmanJun 01.2005 — Are you drunk again? The way you have asked your question makes it seem that way. If you are asking what I think you are asking you could try this:[code=php]<?php

if(eregi('index.php$', $_SERVER['PHP_SELF'])){
print "home";
}
else
{
print "go to home";
}
?> [/code]
Copy linkTweet thisAlerts:
@SheldonauthorJun 04.2005 — i get this error

[b]Parse error: parse error in /Users/sheldon/Sites/test.php on line 3[/b]


using your code bokeh,

by the way, im not sure if i wasdrunk then, but i sure was last night, and boy did i get in trouble today ? ?
Copy linkTweet thisAlerts:
@SheldonauthorJun 04.2005 — Thanks for all of your suggestions, but thanks to [URL=http://jasonpearce.com]jason pearce[/URL] and the [URL=http://alistapart.com/articles/keepingcurrent/]a list apart[/URL] i have made this work for me

in the top of each main page

[code=php]
<?php $page="pagename" ?>
[/code]


and in the menu page

[code=php]
<?php if ($thisPage=="page1") {
echo "page1";

}else{
echo "<a href='page1.php'>page1<?a>";
}
?>
[/code]

and so on and and so on and on.........



Works well and you an use[code=php]<?php print '$page'; ?>[/code] where ever you want to display the page name, such as in your title tag and meta tags and for displaying many different items!



Thans Sheldon
Copy linkTweet thisAlerts:
@bokehJun 04.2005 — Using your code bokeh,i get this error:

[b]Parse error: parse error in /Users/sheldon/Sites/test.php on line 3[/b][/QUOTE]

I can't understand why! It works fine on the two machines I have tried it on.
×

Success!

Help @Sheldon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...