Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Znav
nextExample of a File System Client in PHP
prevApplication Notes for PHP

The Slice compilers can optionally generate checksums of Slice definitions. For slice2php, the --checksum option causes the compiler to generate code that adds checksums to the global array Ice_sliceChecksums. The checksums are installed automatically when the PHP code is first parsed; no action is required by the application.

In order to verify a server's checksums, a client could simply compare the two array objects using a comparison operator. However, this is not feasible if it is possible that the server might return a superset of the client's checksums. A more general solution is to iterate over the local checksums as demonstrated below:

Wiki Markup
{zcode:php}
global $Ice_sliceChecksums;
$serverChecksums = ...
foreach($Ice_sliceChecksums as $key => $value)
{
    if(!isset($serverChecksums[$key]))
        // No match found for type id!
    elseif($Ice_sliceChecksums[$key] != $serverChecksums[$key])
        // Checksum mismatch!
}
{zcode}

In this example, the client first verifies that the server's dictionary contains an entry for each Slice type ID, and then it proceeds to compare the checksums.

Ztop
See Also
Zret
Znav
nextExample of a File System Client in PHP
prevApplication Notes for PHP