问题
I have a one single PHP file in which
first part: Server generates some output.
Second Part:uses the server generated output and submits the information.
what i have done:
File Name: abc.php
<?php
//first part
based on the information here server generates some output say:
111 success: id:104.123/12345678 |value:10000045
//second part
i will be using the output generated in the first part.
what i have done is something like this
$server_said = file_get_contents('http://http://abc.php');
//abc.php is the file name
if (preg_match_all('/104.123\:(\d*)/', $server_said, $matches))
//i want to display only 104.123/12345678 part
{
$input = $matches[1];
}
$xmlfile = '<?xml version="1.0" encoding="UTF-8"?>
<identifier identifierType="id">'.$input.'</identifier>';
?>
error: the intended result is not being displayed at $input, it is just staying as $input
How can i do that?
I am not sure about the code what i have written above might be wrong.
回答1:
your regular expression fails, the correct one is:
if (preg_match_all('/\d+\.\d+\/\d+/', $server_said, $matches))
as well, when your output XML, u need to change your headers to what follows:
header('Content-type: text/xml');
来源:https://stackoverflow.com/questions/7631163/using-response-in-the-same-php-file