- substr: documentation ( source)
- var_dump: documentation ( source)
- serialize: documentation ( source)
- rand: documentation ( source)
- md5: documentation ( source)
<?php
class Cookie{
public $username;
public $coffee;
public $token;
public function __toString() {
return "<p> Hey ".$this->username."! </p><br>" .
"<p> Here is your token for a free ". $this->coffee."!!</p><p>".$this->token."</p><p>Give us this token at your next visit!</p>";
}
}
class Token{
public $coffee;
public $username;
public function __construct($coffee, $username){
$this->coffee = (string)$coffee;
$this->username = (string)$username;
$this->crypto = "crc32";
}
public function __toString(){
$x = $this->crypto;
return substr(md5(rand($x($this->coffee . $this->username), 0xc0ffee)), 10);
}
}
$a = new Token("a","b");
$a->crypto = "c";
var_dump(serialize($a));