Web студия "GrandView"
  Главная   Написать Контакты
   
   
О проекте
Руководство php
 

wddx_deserialize

(PHP 3 >= 3.0.7, PHP 4, PHP 5)

wddx_deserialize -- Alias of wddx_unserialize()

Описание

This function is an alias of: wddx_unserialize().



wddx_packet_end> <wddx_add_vars
Last updated: Fri, 26 Jan 2007
 
add a note add a note User Contributed Notes
wddx_deserialize
dave at codexweb dot co dot za
21-Jan-2006 04:40
Here's a handy wddx_deserialize clone I wrote a while back. It uses PHP5 SimpleXML and recursion to do pretty much the same task as wddx_deserialize. Hope it comes in handy for someone.

<?php

if (!function_exists('wddx_deserialize'))
{
   
/**
     * Clone implementation of wddx_deserialize
     */
   
function wddx_deserialize($xmlpacket)
    {
        if (
$xmlpacket instanceof SimpleXMLElement)
        {
            if (!empty(
$xmlpacket->struct))
            {
               
$struct = array();
                foreach (
$xmlpacket->xpath("struct/var") as $var)
                {
                    if (!empty(
$var["name"]))
                    {
                       
$key = (string) $var["name"];
                       
$struct[$key] = wddx_deserialize($var);
                    }
                }
                return
$struct;
            }
            else if (!empty(
$xmlpacket->array))
            {
               
$array = array();
                foreach (
$xmlpacket->xpath("array/*") as $var)
                {
                   
array_push($array, wddx_deserialize($var));
                }
                return
$array;
            }
            else if (!empty(
$xmlpacket->string))
            {
                return (string)
$xmlpacket->string;
            }
            else if (!empty(
$xmlpacket->number))
            {
                return (int)
$xmlpacket->number;
            }
            else
            {
                if (
is_numeric((string) $xmlpacket))
                {
                    return (int)
$xmlpacket;
                }
                else
                {
                    return (string)
$xmlpacket;
                }
            }
        }
        else
        {
           
$sxe = simplexml_load_string($xmlpacket);
           
$datanode = $sxe->xpath("/wddxPacket[@version='1.0']/data");
            return
wddx_deserialize($datanode[0]);
        }
    }
}

?>
php dot net at werner-ott dot de
24-Nov-2005 12:20
On migrating wddx_deserialize() from PHP 4.x to PHP 5.1 (5.1.0RC6):

While

  $buffer = wddx_serialize_vars($some_array);
  $some_array = wddx_deserialize($buffer);

worked fine with PHP 4.x, the deserialization failed with PHP 5.1. In the above example $some_array will just be an empty string under 5.1

While wddx_serialize_vars() seems to behave identical in 4.x and 5.1, wddx_deserialize() does NOT.

Prepending XML encoding information to the buffer turned out to be at least a workaround. So, the following works with PHP 5.1:

  $buffer = wddx_serialize_vars($some_array);
  $buffer = '<?xml version="1.0"
          encoding="ISO-8859-1"?>'.
          $buffer;
  $some_array = wddx_deserialize($buffer);

NB: It may well be, that the behavioural difference between 4.x and 5.1 described above can only be observed if the array contains certain characters, i.e. german Umlaute (
Новости
11 июля 2007
Сайт запущен
© 2007 info@grandviewstudio.com

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 324

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 330
Z058440144362 Z348613067571