How do I make it read part of the current url in the browser, for example:
Read the "something=something" part of "http:/something.eg/something?something=something"
I searched in Google, but didn't get the right answer.
Offline
Well, you could do something like this:
$something = $_GET['something']
To read the value of "something=something" but other than that i don't know!
Offline
WindowsExplorer wrote:
That doesn't read teh current url from the browser
sorry, misunderstood
Offline
it doesn't have to be in php, just i want a thing so if the url is http://example.com/image?type=example1
It will show a certain image, and if teh url is http://example.com/image?type=2 it shows another image.
Offline
so you COULD use my method to find out which image to display!
Offline
Look, WindowsExplorer:
the "variable=value" bit of the URL
http://domain.com/page?variable=value
is called a GET variable.
So, in this specific context, you can read a value using ohaiderstudios's method:
$_GET['variable']
However, it's true that sometimes you might want to find the full URL of the request. Then you need
$_SERVER['REQUEST_URI']
but not in this case!
Offline
ohaiderstudios wrote:
Well, you could do something like this:
Code:
$something = $_GET['something']To read the value of "something=something" but other than that i don't know!
Oh, sorry ohaiderstudios! I didn't realize. I thought that was to set a global var or something!
Offline
WindowsExplorer wrote:
ohaiderstudios wrote:
Well, you could do something like this:
Code:
$something = $_GET['something']To read the value of "something=something" but other than that i don't know!
Oh, sorry ohaiderstudios! I didn't realize. I thought that was to set a global var or something!
yeah, it's just reading the value of "something=something" and setting it to variable
Offline
WindowsExplorer wrote:
Great! I'm making a CUSTOM UPDATING IMAGE CREATOR!
I figured that's what you were going to do with it
Offline
Also, I don't fully get string replacement. Could someone give me the code, and explain the parts of it?
Offline
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;
}
echo curPageURL();Put the fumction at the top of the page in php tags. I use this one all the time.
Offline
WindowsExplorer wrote:
Also, I don't fully get string replacement. Could someone give me the code, and explain the parts of it?
Heres some example code:
$helloworld = "hello world!"; //sets the variable
//lets replace all "o"s and change it to "v"
$helloworld = replace("o","v",$helloworld);
echo $helloworld;That will show: hellv wvrld!
Basically: replace(replace this, with this, from this);
You can also do blank for the 2nd field, which would remove all of the 1st field from the 3rd field.
Get it?
Offline
WindowsExplorer wrote:
Thanks sparks, fg123, LS97 and orchardstudios!
OHAIDER studios
Offline
ohaiderstudios wrote:
WindowsExplorer wrote:
Thanks sparks, fg123, LS97 and orchardstudios!
OHAIDER studios
LOL, orchard
Offline