
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
How to get parameters from a URL string in PHP?
To get parameters from a URL string in PHP, the code is as follows−
Example
<?php $url = 'http://www.example.com/register?name=demo&email=example12@domain.com'; $res = parse_url($url); parse_str($res['query'], $params); echo 'Email = '.$params['email']; ?>
Output
This will produce the following output−
Email = example12@domain.com
Example
Let us now see another example −
<?php $url = 'http://www.example.com/register?name=demo&email=example12@domain.com'; $res = parse_url($url); parse_str($res['query'], $params); echo 'Email = '.$params['name']; ?>
Output
This will produce the following output−
Email = demo
- Related Articles
- JavaScript - know the value of GET parameters from URL
- How to get an object containing parameters of current URL in JavaScript?
- Node.js – Reading Path Parameters from URL
- How to get a bitmap from Url in Android app?
- Get Last Part of URL in PHP?
- How to read request parameters passed in URL using JSP?
- How to pass reference parameters PHP?
- How to get a variable name as a string in PHP?
- How to get file name from a path in PHP?
- How to get current URL in JavaScript?
- How to get current URL in jQuery?
- How to URL encode a string (NSString) in iPhone?
- Extract hostname from URL string in JavaScript?
- How to get the length of longest string in a PHP array
- How to correctly get a value from a JSON PHP?

Advertisements