Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Web Coding

Reply
 
LinkBack Thread Tools
Old 01-11-08   #1 (permalink)
PC Gamer
 
Boris4ka's Avatar
 
intel nvidia

Join Date: Mar 2006
Location: San Francisco, CA
Posts: 2,829
Blog Entries: 2

Rep: 194 Boris4ka is acknowledged by manyBoris4ka is acknowledged by many
Unique Rep: 0
Trader Rating: 17
Default Fetch current URL in PHP?

Can I fetch the current URL in PHP? I know I can do it using javascript, but I was wondering if there was a PHP function to do it

System: über pwnage
CPU
E6600 3.0GHz 1.4v
Motherboard
Gigabyte GA-P35-S3L
Memory
2x2GB G.Skill 6400 835MHz
Graphics Card
EVGA 8800GTS 320MB
Hard Drive
320GB .10 + 80GB .7
Sound Card
Onboard HD Audio
Power Supply
Rosewill Performance 550W
Case
Centurion 5 w/ side window
CPU cooling
Golden Orb 2 - lapped
GPU cooling
Stock fan
OS
Vista Ultimate x64
Monitor
X191W 19"w + Sony 15" LCDs
Boris4ka is offline Boris4ka's Gallery   Reply With Quote
Old 01-12-08   #2 (permalink)
Programmer
 
Dismounted's Avatar
 
intel ati

Join Date: Oct 2007
Location: Melbourne, Australia
Posts: 339

Rep: 41 Dismounted is acknowledged by some
Unique Rep: 0
Folding Team Rank: 540
Hardware Reviews: 2
Trader Rating: 0
Default

$current_url = 'http://www.example.com' . $_SERVER['PHP_SELF'];
__________________
System: Powered By Xeon
CPU
Intel Xeon X3320 (45nm Quad)
Motherboard
ASUS Maximus "Rampage" Formula SE
Memory
4GB (4x1GB) Crucial Ballistix Tracer DDR2-800
Graphics Card
HIS HD 4850 IceQ 4 Turbo 512MB
Hard Drive
WD Raptor 150GB, WD Caviar SE16 500GB + 250GB
Sound Card
ASUS SupremeFX II
Power Supply
Corsair HX-620
Case
Cooler Master RC-690
CPU cooling
Thermalright Ultima-90I
GPU cooling
IceQ 4 Cooler
OS
Windows Vista 64-bit
Monitor
Samsung 226BW
Dismounted is offline I fold for Overclock.net   Reply With Quote
Old 01-12-08   #3 (permalink)
PC Gamer
 
Boris4ka's Avatar
 
intel nvidia

Join Date: Mar 2006
Location: San Francisco, CA
Posts: 2,829
Blog Entries: 2

Rep: 194 Boris4ka is acknowledged by manyBoris4ka is acknowledged by many
Unique Rep: 0
Trader Rating: 17
Default

Won't that just set the var "current_url" to example.com? I need it to grab the url that the page is at. For example: when you're at example.com/link1.php, I want that to be the current url, and when you're at example.com/index.php that to be current url, etc.

System: über pwnage
CPU
E6600 3.0GHz 1.4v
Motherboard
Gigabyte GA-P35-S3L
Memory
2x2GB G.Skill 6400 835MHz
Graphics Card
EVGA 8800GTS 320MB
Hard Drive
320GB .10 + 80GB .7
Sound Card
Onboard HD Audio
Power Supply
Rosewill Performance 550W
Case
Centurion 5 w/ side window
CPU cooling
Golden Orb 2 - lapped
GPU cooling
Stock fan
OS
Vista Ultimate x64
Monitor
X191W 19"w + Sony 15" LCDs
Boris4ka is offline Boris4ka's Gallery   Reply With Quote
Old 01-13-08   #4 (permalink)
Programmer
 
Dismounted's Avatar
 
intel ati

Join Date: Oct 2007
Location: Melbourne, Australia
Posts: 339

Rep: 41 Dismounted is acknowledged by some
Unique Rep: 0
Folding Team Rank: 540
Hardware Reviews: 2
Trader Rating: 0
Default

Did you read the whole line? A period (dot) is the PHP concatenation character, it joins two things together.
__________________
System: Powered By Xeon
CPU
Intel Xeon X3320 (45nm Quad)
Motherboard
ASUS Maximus "Rampage" Formula SE
Memory
4GB (4x1GB) Crucial Ballistix Tracer DDR2-800
Graphics Card
HIS HD 4850 IceQ 4 Turbo 512MB
Hard Drive
WD Raptor 150GB, WD Caviar SE16 500GB + 250GB
Sound Card
ASUS SupremeFX II
Power Supply
Corsair HX-620
Case
Cooler Master RC-690
CPU cooling
Thermalright Ultima-90I
GPU cooling
IceQ 4 Cooler
OS
Windows Vista 64-bit
Monitor
Samsung 226BW
Dismounted is offline I fold for Overclock.net   Reply With Quote
Old 01-13-08   #5 (permalink)
AMD Overclocker
 
Starholdest's Avatar
 
amd nvidia

Join Date: Mar 2007
Location: █♣█
Posts: 928
Blog Entries: 1

Rep: 43 Starholdest is acknowledged by some
Unique Rep: 0
Hardware Reviews: 1
Trader Rating: 0
Default

This should do the trick:

<?php
echo "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
?>

__________________

My s939 rig build log thread - 4600+ @ 2.8Ghz stable


Aumotocnic "An unfortunate member of the overclock.net insomnia club"

Quebec Overclockers - 8019 in 3dMark06

s939 Manny 4600+ @ 2809Mhz @ 1.425V (9 hours Orthos blend test stable - 24/7 Usage) - http://valid.x86-secret.com/show_oc.php?id=289741
@ 2945Mhz @ 1.45V (YAY! - Not stable, doh!) - http://valid.x86-secret.com/show_oc.php?id=276669

System: Beast from the East
CPU
AMD x2 4600+ @ 2.8Ghz
Motherboard
Asus A8N-SLI SE
Memory
2GB Kingston Value DDR400
Graphics Card
Asus 8800GTS 320MB
Hard Drive
80G Seagate SATA
Sound Card
SoundBlaster Audigy SE
Power Supply
Thermaltake Purepower 500W
Case
Antec 900 (modded)
CPU cooling
AS5 + Zalman CNPS9700 LED
GPU cooling
Stock
OS
Windows Vista Ultimate
Monitor
Samsung Syncmaster 730B (17" yay!)

Last edited by Starholdest : 01-13-08 at 06:50 PM.
Starholdest is offline Starholdest's Gallery   Reply With Quote
Old 01-13-08   #6 (permalink)
Programmer
 
LyokoHaCk's Avatar
 
amd nvidia

Join Date: Aug 2006
Location: United States Inc.
Posts: 1,995

Rep: 74 LyokoHaCk is acknowledged by some
Unique Rep: 0
FAQs Submitted: 1
Trader Rating: 2
Default

Starholdest got it.
LyokoHaCk is offline   Reply With Quote
Old 01-14-08   #7 (permalink)
Programmer
 
Dismounted's Avatar
 
intel ati

Join Date: Oct 2007
Location: Melbourne, Australia
Posts: 339

Rep: 41 Dismounted is acknowledged by some
Unique Rep: 0
Folding Team Rank: 540
Hardware Reviews: 2
Trader Rating: 0
Default

Quote:
Originally Posted by Starholdest View Post
This should do the trick:

<?php
*snip*
?>

If you're coding for your own website, my solution would be more ideal (and faster) as PHP doesn't have to concatenate the extra variable put in there. Also, a word of advice, use single quotes instead of double as it is faster because PHP doesn't have to scan for variables in that string. If you need to put a variable into a string, concatenate. Another thing (I'm picky ), you should space out your coding properly, it makes it much easier for you and (if applicable) your colleagues.

As you can see, I'm all about efficiency, speed and readability, instead of the "easy way out".
__________________
System: Powered By Xeon
CPU
Intel Xeon X3320 (45nm Quad)
Motherboard
ASUS Maximus "Rampage" Formula SE
Memory
4GB (4x1GB) Crucial Ballistix Tracer DDR2-800
Graphics Card
HIS HD 4850 IceQ 4 Turbo 512MB
Hard Drive
WD Raptor 150GB, WD Caviar SE16 500GB + 250GB
Sound Card
ASUS SupremeFX II
Power Supply
Corsair HX-620
Case
Cooler Master RC-690
CPU cooling
Thermalright Ultima-90I
GPU cooling
IceQ 4 Cooler
OS
Windows Vista 64-bit
Monitor
Samsung 226BW
Dismounted is offline I fold for Overclock.net   Reply With Quote
Old 01-14-08   #8 (permalink)
PC Gamer
 
Boris4ka's Avatar
 
intel nvidia

Join Date: Mar 2006
Location: San Francisco, CA
Posts: 2,829
Blog Entries: 2

Rep: 194 Boris4ka is acknowledged by manyBoris4ka is acknowledged by many
Unique Rep: 0
Trader Rating: 17
Default

Dismounted, I tried your script but it didn't work. But starholdest's did. Thanks to both of you for your help

System: über pwnage
CPU
E6600 3.0GHz 1.4v
Motherboard
Gigabyte GA-P35-S3L
Memory
2x2GB G.Skill 6400 835MHz
Graphics Card
EVGA 8800GTS 320MB
Hard Drive
320GB .10 + 80GB .7
Sound Card
Onboard HD Audio
Power Supply
Rosewill Performance 550W
Case
Centurion 5 w/ side window
CPU cooling
Golden Orb 2 - lapped
GPU cooling
Stock fan
OS
Vista Ultimate x64
Monitor
X191W 19"w + Sony 15" LCDs
Boris4ka is offline Boris4ka's Gallery   Reply With Quote
Old 01-14-08   #9 (permalink)
Programmer
 
Dismounted's Avatar
 
intel ati

Join Date: Oct 2007
Location: Melbourne, Australia
Posts: 339

Rep: 41 Dismounted is acknowledged by some
Unique Rep: 0
Folding Team Rank: 540
Hardware Reviews: 2
Trader Rating: 0
Default

What do you mean it didn't work? You mean it didn't output anything? That's because it wasn't printed, use echo() instead of assigning it to a variable.
__________________
System: Powered By Xeon
CPU
Intel Xeon X3320 (45nm Quad)
Motherboard
ASUS Maximus "Rampage" Formula SE
Memory
4GB (4x1GB) Crucial Ballistix Tracer DDR2-800
Graphics Card
HIS HD 4850 IceQ 4 Turbo 512MB
Hard Drive
WD Raptor 150GB, WD Caviar SE16 500GB + 250GB
Sound Card
ASUS SupremeFX II
Power Supply
Corsair HX-620
Case
Cooler Master RC-690
CPU cooling
Thermalright Ultima-90I
GPU cooling
IceQ 4 Cooler
OS
Windows Vista 64-bit
Monitor
Samsung 226BW
Dismounted is offline I fold for Overclock.net   Reply With Quote
Old 01-14-08   #10 (permalink)
PC Gamer
 
Boris4ka's Avatar
 
intel nvidia

Join Date: Mar 2006
Location: San Francisco, CA
Posts: 2,829
Blog Entries: 2

Rep: 194 Boris4ka is acknowledged by manyBoris4ka is acknowledged by many
Unique Rep: 0
Trader Rating: 17
Default

Quote:
Originally Posted by Dismounted View Post
What do you mean it didn't work? You mean it didn't output anything? That's because it wasn't printed, use echo() instead of assigning it to a variable.
I just added echo('$current_url') at the end of the line. Did I do that wrong?

System: über pwnage
CPU
E6600 3.0GHz 1.4v
Motherboard
Gigabyte GA-P35-S3L
Memory
2x2GB G.Skill 6400 835MHz
Graphics Card
EVGA 8800GTS 320MB
Hard Drive
320GB .10 + 80GB .7
Sound Card
Onboard HD Audio
Power Supply
Rosewill Performance 550W
Case
Centurion 5 w/ side window
CPU cooling
Golden Orb 2 - lapped
GPU cooling
Stock fan
OS
Vista Ultimate x64
Monitor
X191W 19"w + Sony 15" LCDs
Boris4ka is offline Boris4ka's Gallery   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 11:16 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.23458 seconds with 9 queries