0

Here is a small Java Code Snippet.

ConfigData[] cd = new ConfigData[1];
cd[0] = new ConfigData();
byte[] tmpbyte ={1,(byte)0x01};
cd[0].settmpdata(tmpbyte);

"ConfigData" is my custom Type (int, Byte Array).

In my last thread i found the tip how to Build / work with a "ByteArray" in php. But this seems to be a question of the structure of those objects / array.

So.. How can i depict that in PHP.

4

1 回答 1

1

我希望这可以为您提供一些指导,就您可以在 PHP 中执行的操作以及与您的代码片段(代码经过测试)的关系而言:

<?php

// define class
class ConfigData
{
    var $intVal;
    var $tmpData;
}

$cData = new ConfigData();             // new ConfigData instance
$array[0] = $cData;                 // put it in a single element array
$array[0]->intVal = 5;                 // assign an integer to intVal
$array[0]->tmpData = array(1, 1, 2);  // assign an array of whatever to tmpData

foreach($array[0]->tmpData as $val)   // iterate through assigned array
    echo $val." ";                     // print array item (and append " " )

?>

现在,您可能还想检查 PHP 中的字节操作是如何实现的。我建议你做一点谷歌搜索,也许查看官方手册。你的问题不够具体,所以我不能多说。

于 2012-10-30T11:23:00.213 回答