PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Pavel  >  BEncoded  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Usage example
Class: BEncoded
Read and write torrent files in the Bencode format
Author: By
Last change:
Date: 9 years ago
Size: 412 bytes
 

Contents

Class file image Download
<?php
require 'bencoded.php';

$be = new BEncoded;

$be->NewNode('dict', 'child');
$be->Set('child/key', 'value');
$be->Set('child/_key', '_val');

echo
$be->ToString(); // => d5:childd4:_key4:_val3:key5:valueee

$be->FromFile('1.torrent');
// or this, which is the same:
//$be = new BEncoded(file_get_contents('1.torrent'));
echo $be->InfoHash(); // => DFE39EFFF439B78BB2DD2CAEB69B72ACFE660710

For more information send a message to info at phpclasses dot org.