Page 1 of 1
Php function
Posted: Wed Jun 02, 2010 10:40 am
by sejpal.dipesh
Hi,
Please help me as i am very new to php.
Is their any php function which can help me do following thing.
i.e
http://www.domainname.com/xyzinfo.php?xyzid=50
i want function to just return me the xyzid, for eg in above case 50.
Thank You,
Re: Php function
Posted: Wed Jun 02, 2010 10:57 am
by phu
What you're referring to is a GET parameter. PHP passes them to the script as part of the $_GET
superglobal.
Re: Php function
Posted: Wed Jun 02, 2010 1:43 pm
by sejpal.dipesh
Thank you for your quick reply but this is not what i want.
I just want the id, i know it can be done via string function,
it would be great if you can guide me with that.
Re: Php function
Posted: Wed Jun 02, 2010 2:10 pm
by phdatabase
Code: Select all
$string = 'http://www.domainname.com/xyzinfo.php?xyzid=50';
$string = str_replace( '?', '', strstr( $string, '?');
$string = strstr( $string, '=', true);
Re: Php function
Posted: Wed Jun 02, 2010 2:46 pm
by AbraCadaver
Code: Select all
parse_str(parse_url('http://www.domainname.com/xyzinfo.php?xyzid=50', PHP_URL_QUERY));
echo $xyzid;