Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

这样的代码怎么解析呢?谢谢

[复制链接]
myth111 发表于 2010-3-10 14:42:02 | 显示全部楼层 |阅读模式
新手,这样的数据a:2:{s:8:\"username\";s:2:\,服务端如何解析呢

在学习插件制作,发现有这个提交动作,提交到一个服务器的页面,页面接受参数,返回点状态啥的
        $url = "http://127.0.0.1/server/plugin.php";
        $responce = array();
        $request = urlencode(serialize($request));
if (function_exists('dfopen')) {
                $responce = dfopen($url, '', 'data=' . $request);

        }
。。。
      
        $responce = unserialize(urldecode($responce));

        return $responce;

我服务器端代码如下,取到的data使这样格式,不知道如何比较清晰的得到username和password的值呢?
谢谢~
服务器接收程序
$type=$_REQUEST["type"];
$tm=$_REQUEST["tm"];
$mac=$_REQUEST["mac"];
$data=$_REQUEST["data"];

        $data =  (urldecode($data));


file_put_contents("zhwan_plugin_log.txt", time() ."type == $type tm == $tm mac == $mac data == $data");
看到的dat是这样的
data == a:2:{s:8:\"username\";s:2:\"ss\";s:8:\"password\";s:2:\"ss\";}

请问怎么解析到username和password值
还有返回应该是什么格式,加个什么函数返回呢该

谢谢
leonswin 发表于 2010-3-10 14:52:19 | 显示全部楼层
不太清楚,帮顶!
回复

使用道具 举报

 楼主| myth111 发表于 2010-3-10 14:57:57 | 显示全部楼层
$data="a:2:{s:8:\"username\";s:4:\"ssss\";s:8:\"password\";s:4:\"ssss\";}";
$array = array();
$array =  unserialize( ($data));
echo "<pre>\n";

print_r($array);

Array
(
    [username] => ssss
    [password] => ssss
)

很好这样,
但是我上头那段就出不来呢
回复

使用道具 举报

№11买空间网 发表于 2010-3-10 15:08:19 | 显示全部楼层
友情帮顶~~
回复

使用道具 举报

 楼主| myth111 发表于 2010-3-10 15:18:55 | 显示全部楼层
$data=stripslashes(($_REQUEST["data"]));
就好了
直接崩溃了,准备休息的时候,灵感来了。奔溃
回复

使用道具 举报

狂人采集器 发表于 2010-3-10 16:45:10 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-7-3 22:55 , Processed in 0.093544 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表