Page 1 of 1

Referer base withOUT ?something=something&somerthing....

Posted: Thu May 17, 2007 2:59 pm
by JAB Creations
I need to have just the base file name of the referer without any trailing stuff from ?something=something and so on. However using PHP's base function does not remove anything after the file extension. I need to remove all URI commands/queries/properties/values whatever they are referred to as but keep the refering file name intact.

So if the referer was index.php?audio=1&connection=2 I want to strip the referer down to index.php. How do I do this?

Posted: Thu May 17, 2007 3:44 pm
by feyd

Posted: Fri May 18, 2007 11:39 pm
by JAB Creations
Well it looks like something I could use, if only there were examples for people who haven't been working with PHP for the past five years straight. :?

Posted: Fri May 18, 2007 11:48 pm
by volka
??
"Example 2493. A parse_url() example" is straight forward. What do you not understand?
You pass an url to parse_url and it returns an array containing the different parts or fth url.

Posted: Sat May 19, 2007 12:18 am
by JAB Creations
Ok I'm not sure the answer to my original question but somehow I answered a question to a more advanced version of this with AJAX.

Using AJAX to include an XHTML file (after the page loads in order to reduce initial page load size) I wanted to have a form on the AJAX includes file. However if I echoed the page's self location it would spit out the AJAX file name instead of the page (say index.php). I have learned a little bit about return...


index.php

Code: Select all

ajaxpage('templates/ajax-prompt-theme.php?return=<?php echo $_SERVER['PHP_SELF'];?>', 'themes');
AJAX includes...

Code: Select all

<?php echo basename($_GET['return']); ?>
The AJAX code I use can be found at...
http://www.dynamicdrive.com/dynamicinde ... ontent.htm

I can understand out-of-the-box stuff, I just am not sure about dynamically creating this stuff, mostly because no one is posting any examples!

Posted: Sat May 19, 2007 6:58 am
by feyd
Your echo should probably be passed through rawurlencode() prior to echoing. Also, be very careful using PHP_SELF anywhere; it contains user input and can open you to insertion attacks.