在同一个 PHP 文件中使用 Response [英] Using Response in the same PHP file

查看:61
本文介绍了在同一个 PHP 文件中使用 Response的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个单独的 PHP 文件,其中

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.

我做了什么:

文件名:abc.php

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>'; 

?>

错误:预期的结果没有显示在 $input 处,它只是停留在 $input

error: the intended result is not being displayed at $input, it is just staying as $input

我该怎么做?

我不确定我上面写的代码可能是错误的.

I am not sure about the code what i have written above might be wrong.

推荐答案

你的正则表达式失败,正确的是:

your regular expression fails, the correct one is:

if (preg_match_all('/\d+\.\d+\/\d+/', $server_said, $matches))

同样,当您输出 XML 时,您需要将标题更改为以下内容:

as well, when your output XML, u need to change your headers to what follows:

header('Content-type: text/xml');

这篇关于在同一个 PHP 文件中使用 Response的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆