Forum Moderators: coopster

Message Too Old, No Replies

Var passing problem

Not sure how todo this.

         

adamnichols45

5:11 pm on Apr 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok bascially here is the problem.

I have articles that i save as example

blue.php
white.php
red.php

on all of these pages i have an include file

review.php

But what i need to do is tell review.php what page it is being displayed on at the time.

How can i do this?

DanA

7:31 pm on Apr 9, 2006 (gmt 0)

10+ Year Member



You can use $_SERVER["REQUEST_URI"] in review.php to find which page is to be displayed.

adamnichols45

9:26 pm on Apr 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Cheers for that...

I need to strip some of the characters = example

$ad = $_SERVER["REQUEST_URI"];
echo $ad;

returns

/articles/prices.php

but i just want it to return prices.php

DanA

8:25 am on Apr 10, 2006 (gmt 0)

10+ Year Member



you can use
$ad=ereg_replace(".*\/","",$_SERVER["REQUEST_URI"]);

adamnichols45

9:51 am on Apr 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thats excellent and saved me not only alot of bandwidth but alot of coding also.

Thanks

adamnichols45

10:47 am on Apr 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



O i just spotted something...

I have played around with it but it keeps displaying an error.

$ad=ereg_replace(".*\/","",$_SERVER["REQUEST_URI"]);

returns widget1.php

i need to strip the .php to just leave widget1

Im going to keep trying but anyone mind lending a hand.

adamnichols45

10:53 am on Apr 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$ad=ereg_replace(".*\/","",$_SERVER["REQUEST_URI"]);

$add = str_replace('.php', '', $ad);
echo $add;

Ok that seems to work..

Anybody see any problems with that code..