...

View Full Version : url variable



powerfear
10-17-2009, 03:04 AM
Hello,

I saw few site who have example url like this:

example.com/test.php?qweqwe (notice there is no variable name and no "=")

I'm wondering how could i do the same i tried



<?php
$var1 = $_GET[NULL];
echo $var1;
?>


but its not working if anyone know how to do this i would appreciate your reply.

bucket
10-17-2009, 03:33 AM
I got something like:

test.php?message=hi

Will that be any good?

powerfear
10-17-2009, 03:41 AM
I got something like:

test.php?message=hi

Will that be any good?

no that's a simple $_GET['message']
im looking for a way to do it without any variable name and "="

edit: here an live example http://www.mediafire.com/index.php?ysj2hzetga0

tailender1
10-17-2009, 08:16 AM
just check out the w3schools explanation on $_GET
http://www.w3schools.com/PHP/php_get.asp
but i dont recomment $_GET. use url rewriting to make dynamic pages.
just search google for url rewriting in php / apache you will see tons of tutorials on that
scripts with lots of parameters are not Search engine friendly

er4o
10-17-2009, 10:37 AM
Try to check if the $_GET['qweqwe'] is setted.



<?php
if (isset($_GET['qweqwe'])) {
echo "qweqwe is setted";
}

met
10-17-2009, 11:41 AM
here


$pageURL = $_SERVER["REQUEST_URI"];

$foo = explode('?', $pageURL);
echo $foo[0]; // example.com/test.php
echo $foo[1]; //'qweqwe';


go figure _^

i had found some function to return the whole URL but it wasn't necessary.

powerfear
10-17-2009, 04:37 PM
here


$pageURL = $_SERVER["REQUEST_URI"];

$foo = explode('?', $pageURL);
echo $foo[0]; // example.com/test.php
echo $foo[1]; //'qweqwe';


go figure _^

i had found some function to return the whole URL but it wasn't necessary.

Well this work good thanks

Fou-Lu
10-17-2009, 04:50 PM
isset is the right approach, but will return false on null values. Instead, check using array_key_exists('qweqwe', $_GET);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum