hi i was wondering how i can get a certain part of a url in php. For example a url like http://site.com/randomfile.
what i want is only the site.com part. How can i do this?
nick3592
0
Light Poster
Recommended Answers
Jump to Post<?php function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } ?> <?php echo curPageURL(); ?> <!-- Sometimes it is needed to get …
All 4 Replies
rajarajan2017
nick3592
0
Light Poster
blocblue
238
Posting Pro in Training
Featured Poster
nick3592
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.