LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 02-28-2008, 08:34 AM   #1
rubadub
Member
 
Registered: Jun 2004
Posts: 233

Rep: Reputation: 33
Getting anchors from link in PHP


Hi, i'm doing a duel pagination thing and I need to be able to grab the anchor part of the URL, but I seem to be running into a roadblock through general searching. I've tried looking through all server variables etc...
Code:
while (list($k, $v) = each($_SERVER))
{
	print "'".$k."' => '".$v."' <br>";
}
Basically i've got a link, say 'http://www.a.com/index.html#here' and I need to get the 'here' bit... Has anybody got a solution please?
 
Old 02-28-2008, 11:36 AM   #2
nc3b
Member
 
Registered: Aug 2005
Posts: 330

Rep: Reputation: 32
What's wrong with explode or preg_split?
PHP Code:
$str='http://www.a.com/index.html#here';
$str=explode("#",$str);
print_r($str); 
Cheers.
 
Old 02-28-2008, 01:53 PM   #3
rubadub
Member
 
Registered: Jun 2004
Posts: 233

Original Poster
Rep: Reputation: 33
Because it's not passed through. It gets to the log's but not into the $_SERVER variables...
 
Old 02-28-2008, 02:03 PM   #4
nc3b
Member
 
Registered: Aug 2005
Posts: 330

Rep: Reputation: 32
ooooh) Silly me. I misread.
Well, I'm not sure, but my best guess is that it never gets to the server. What could the server do with that? It generates the exact same thing with or without it, it's there only for your browser to know where to scroll the page.. I would try javascript for this problem, here php is no good. Cheers.

PS, if someone does find I am wrong and can provide a way for php to get the anchor, it would be wonderful, should he post an example

Last edited by nc3b; 02-28-2008 at 02:04 PM.
 
Old 02-28-2008, 02:24 PM   #5
rubadub
Member
 
Registered: Jun 2004
Posts: 233

Original Poster
Rep: Reputation: 33
mmm...

I'm using something like this for the foreseeable future:
Code:
index.html?pos_id=33#id33
A little mixture of a GET and anchor... works but it does seem strange that you can't get the anchor part, I can foresee numerous situations where it'd be useful knowledge, suppose just have to do it like this...

Cheers
 
  


Reply

Tags
php


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I link PHP files? rblampain Programming 9 02-17-2008 12:00 AM
problem about GD library link to PHP arcow Linux - Software 4 02-03-2006 03:09 AM
PHP - MySQL link StarLion Fedora 4 09-10-2005 12:05 PM
i cant link a php frame to another page meluser Linux - Software 0 03-15-2003 12:17 AM
PHP Link Handling Citizen Bleys Programming 1 10-10-2001 04:02 PM


All times are GMT -5. The time now is 04:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration