PHP Class - How to use [closed]

-6

How to use a specific class in php?

For example:

<?php
class Torrent
{
    public function scrape(array $announce = [ ] , $hash_info = null)
    {

        $r = [
            'seeders'  => 0 ,
            'leechers' => 0
        ];

        foreach ( $announce as $an ) {

            $d = get_remote_peers($an , $hash_info);

            if ( isset($d['seeders']) ) {
                $r['seeders'] += $d['seeders'];
            }

            if ( isset($d['leechers']) ) {
                $r['leechers'] += $d['leechers'];
            }
        }

        return $r;
    }

}
?>

How do I use this class?

I tested like this:

<?php

$meuObjeto = new Torrent();

$meuObjeto->scrape("$r"); 

?>

and so

<?php

$meuObjeto = new Torrent();

$meuObjeto->scrape("udp://fopen.demonii.com", 7C90CFEE93DE8C4FA04526DAA5CE530ADFB8DF6E); 

?>

unsuccessful ...

  

Parse error: syntax error, unexpected 'C90CFEE93DE8C4FA04526DAA5CE530'   (T_STRING) in C: \ xampp \ htdocs \ gamepatch \ udpscrap.php on line 457

    
asked by anonymous 21.04.2014 / 20:18

1 answer

4

Looking at your code I noticed the following error in line 3 of this code

<?php
$meuObjeto = new Torrent();
$meuObjeto->scrape("udp://fopen.demonii.com", 7C90CFEE93DE8C4FA04526DAA5CE530ADFB8DF6E); 
?>

The second parameter of the scape() method needs quotation marks (single or double, whatever) so that the format of this parameter becomes .
So it should look like this:

<?php
$meuObjeto = new Torrent();
$meuObjeto->scrape("udp://fopen.demonii.com", "7C90CFEE93DE8C4FA04526DAA5CE530ADFB8DF6E"); 
?>
    
21.04.2014 / 22:06