/    Sign up×
Community /Pin to ProfileBookmark

parse_url(), $_REQUEST_URL help needed

Alright, on my site I need to be able to get the current url of the page then take it apart so i only have the end filename. (i.e.: the url is [url]http://www.blah.com/foo/foo.php[/url]
and i get foo.php)

ive heard of a function parse_url that seems to fit my purpose and a variable that gets the current url, $_REQUEST_URL.

And I’m 100% lost on both… and PHP.net gives the worst explanations, everything relevant i know of php i learned from w3schools. will someone plz help me?

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@Paul_JrFeb 19.2004 — Well so far I've been muddling my way around PHP, reading posts, going to sites and stuff, so I dunno if this will work, or if it's even correct.
[code=php]
<?php
$string = "http://projep.t35.com/foo/foo.php";
$newstring = explode("/", $string);
echo $newstring[4];
?>
[/code]

That will echo out "foo.php".

I just looked this up in the PHP Manual and played about with it. ?
Copy linkTweet thisAlerts:
@Ben_RogersauthorFeb 19.2004 — That sounds like it'll work perfectly!

Now i need a variable for the page's own url...

and what's this php manual you speak of?
Copy linkTweet thisAlerts:
@fredmvFeb 19.2004 — [i]Originally posted by omega [/i]

[B]and what's this php manual you speak of? [/B][/QUOTE]
http://www.php.net/
Copy linkTweet thisAlerts:
@Ben_RogersauthorFeb 19.2004 — oh i call that php.net, not the manual lol

o yeah, and i think i found the solution to the needing the header part... i made a test script and it worked
[code=php]
<?php
$string = $_SERVER['PHP_SELF'];
$newstring = explode("/", $string);
echo $newstring[2];
?>
[/code]

Obviously it'll require tweaking but i think i'll b able to handle it.

Thanks everyone ?
Copy linkTweet thisAlerts:
@Paul_JrFeb 19.2004 — [i]Originally posted by omega [/i]

[B]oh i call that php.net, not the manual lol

o yeah, and i think i found the solution to the needing the header part... i made a test script and it worked

[code=php]
<?php
$string = $_SERVER['PHP_SELF'];
$newstring = explode("/", $string);
echo $newstring[2];
?>
[/code]

Obviously it'll require tweaking but i think i'll b able to handle it.

Thanks everyone ? [/B][/QUOTE]

Always glad to help. ?
Copy linkTweet thisAlerts:
@Ben_RogersauthorFeb 19.2004 — Good to know. You know if it weren't for these forums I wouldn't have even considered learning php?
Copy linkTweet thisAlerts:
@Paul_JrFeb 19.2004 — If it weren't for this forum, I doubt I'd be learning [i]anything[/i]. ? I started out with HTML Goodies, recommended by some guy I used to know, and one day I clicked on the "forums" link at the top, and badda-bing, here I am now. ?
Copy linkTweet thisAlerts:
@Ben_RogersauthorFeb 21.2004 — javascript source was my referral... but i had already learned xhtml, css, and some js... this forum more taught me about web design... how to use these resources effectively. its an excellent example of how affiliation works.
×

Success!

Help @Ben_Rogers 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.19,
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,
)...