Using Response in the same PHP file

女生的网名这么多〃 提交于 2019-12-10 23:07:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!