Possible to put if else on request_uri
Posted: Tue May 01, 2012 1:32 pm
Hello, I have this:
<?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
The problem probably is that strpos() return FALSE when it doesn't find '?' in $request_uri. and it returns empty string.
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
<?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
The problem probably is that strpos() return FALSE when it doesn't find '?' in $request_uri. and it returns empty string.
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