Php function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sejpal.dipesh
Forum Newbie
Posts: 2
Joined: Wed Jun 02, 2010 10:36 am

Php function

Post 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,
phu
Forum Commoner
Posts: 61
Joined: Tue Mar 30, 2010 6:18 pm

Re: Php function

Post by phu »

What you're referring to is a GET parameter. PHP passes them to the script as part of the $_GET superglobal.
sejpal.dipesh
Forum Newbie
Posts: 2
Joined: Wed Jun 02, 2010 10:36 am

Re: Php function

Post 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.
User avatar
phdatabase
Forum Commoner
Posts: 83
Joined: Fri May 28, 2010 10:02 am
Location: Fort Myers, FL

Re: Php function

Post by phdatabase »

Code: Select all

$string = 'http://www.domainname.com/xyzinfo.php?xyzid=50';
$string = str_replace( '?', '', strstr( $string, '?');
$string = strstr( $string, '=', true);
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Php function

Post by AbraCadaver »

Code: Select all

parse_str(parse_url('http://www.domainname.com/xyzinfo.php?xyzid=50', PHP_URL_QUERY));
echo $xyzid;
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply