Hi,

I am using $_SERVER['REQUEST_URI'] ; to get the complete URL address, but in that i want to take only the half, example in $_SERVER['REQUEST_URI'] ; i get http://www.mystore.website.com/index.php?fkdsjklfjdskldfd=id...
but i want to take only till http://www.mystore.website.com, how can i do it?

In PHP is there any function called LastIndex and Substing to use? I am confused. Please help me.

Recommended Answers

All 6 Replies

Hi,

I am doing like this

$myURL = $_SERVER['REQUEST_URI'];
        $lastIndex = lastIndexOf($myURL,'/');
        $myURL = substr($myURL,0,$lastIndex);
        //echo $myURL;

But nothing is happening. instead of '/' what i can use ... plz help

Hey, sorry for the post. I got it resolved. I was supposed to use $lastIndex = strrpos($myURL, '/', 0); instead of $lastIndex = lastIndexOf($myURL,'/');.

echo $_SERVER["HTTP_HOST"].$_SERVER['php_self']

Member Avatar for diafol

Second the parse_url().

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.