- mt_rand: documentation ( source)
- sprintf: documentation ( source)
<?php
class Foo
{
protected $bar = 23;
public function getBar() { return $this->bar; }
public function getBaz() { return mt_rand(0,1); }
}
$foo = new Foo();
echo sprintf('Testing %s', $foo->getBaz() ?: 'ID#'.$foo->getBar());