Hello, I was wondering if I can put an if else, I just cannot get it to work. The problem is that strpos() return FALSE when it doesn't find '?' in $request_uri. and it returns empty string. <?php $request_uri = $_SERVER['REQUEST_URI']; // find position of '?' in a string $position = strpos($request_uri, 0, '?'); // take out part of string $path = substr($request_uri, 0, $position); // form url $url = 'http://www.mysite.com'.$path.'?'; ?> This is my url: <?php echo $url?>jr_listings=bed-and-breakfasts I was wondering if there it was possible to put and if and }else{ so that if there is no '?' in the request_uri, then I still get the request_uri string. I have been working on this all day and just cannot get it to work
There are easier ways to break down a URL, such as parse_url(). With that said, you can create conditionals in this form: $position=( ($c=strpos($request_uri,0,"?")!="")?$c:strlen($request_uri); This will require some modification, pending how strpos() acts.