Title: How to read a string variable in php as $_GET or $_POST?
Tags: php
Question: How can I read a string as query like when you go to https://www.youtube.com/get_vide_info?v={{video_id}}
it will give an information as a query ( if you put it in $_GET ) the PHP will read it manually!
How can I read it without passing it in $_GET like if there is a function
Example:
<?php
$s = file_get_contents('https://www.youtube.com/get_vide_info?v={{video_id}}');
// for example it returned status=failed&amp;error=404&amp;reason=copyright
//how can read status and error and reason
// for example
echo "reject reason $s-&gt;reason ";
echo "status $s-&gt;status ";
Comment: removed non-related tag and some other stuff

Comment: *( must read )* ??

Comment: RohitS you don't understand the question. any way i got the answer from 3161993

Comment: whats the problem in reading from request?? ie $_GET or something $_SERVER. also how you wish to get data parsing string or request object?

Here is the accepted answer: One easy option is to use parse_str(), which you can access as array, if you want as object you have to convert it into object.
// arg1 =&gt; query string
// arg2 =&gt; output array
parse_str($your_string_response, $output);
echo $output['reason'];
echo $output['status'];
Test Results:
$ cat test.php
<?php
$string = "status=failed&amp;error=404&amp;reason=copyright";
parse_str($string, $output);
print_r($output); // as array
print_r((object)$output); // as object
Output:
$ php test.php
[status] =&gt; failed
[error] =&gt; 404
[reason] =&gt; copyright
stdClass Object
[status] =&gt; failed
[error] =&gt; 404
[reason] =&gt; copyright
Comment for this answer: @JamalAbo yes, but if you just want one element, access like `$output['reason']`, please read https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work

Here is another answer: you can read queryString with a magic field $_GET['NameOfQuery'];
$s=array("status"=&gt;$_GET['status'],
"error"=&gt;$_GET['error'],
"reason"=&gt;$_GET['reason']);
// out
echo "reject reason:".$s['reason'];
echo "status :".$s['status'];
echo "error :".$s['error'];;

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:10/20/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<php>', 'Title': 'How to read a string variable in php as $_GET or $_POST?', 'ViewCount': 227, 'id': 46844051, 'user_AboutMe': '<p>Developer, Software Engineer</p>\n', 'user_AccountId': 10323587.0, 'user_DisplayName': 'Jamal Abo', 'user_Reputation': 461.0, 'user_Views': 98.0, 'user_id': 7615694.0}}