<?php
class a {
public $a = 1;
public $b = 2;
}
$obj = new a();
foreach ($obj as $value) {
echo $value.'|';
}
//1|2
?>
<?php
class MyIterator implements Iterator
{
private $var = array();
public function __construct($array)
{
if (is_array($array)) {
$this->var = $array;
}
}
public function rewind()
{
echo "перемотка в начало\n";
reset($this->var);
}
public function current()
{
$var = current($this->var);
echo "текущий: $var\n";
return $var;
}
public function key()
{
$var = key($this->var);
echo "ключ: $var\n";
return $var;
}
public function next()
{
$var = next($this->var);
echo "следующий: $var\n";
return $var;
}
public function valid()
{
$key = key($this->var);
$var = ($key !== NULL && $key !== FALSE);
echo "верный: $var\n";
return $var;
}
}
$values = array(1,2,3);
$it = new MyIterator($values);
foreach ($it as $a => $b) {
print "$a: $b\n";
}
?>
$notifier = new Notifier(new Sms());
$notifier->send ....
$notifier = new Notifier(new Mail());
$notifier->send....
Yii::trace($token);
throw new \Exception('1');
if ($this->iterator == 2) {
throw new \Exception('1');
}
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
'allowedIPs' => ['*'],
];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'allowedIPs' => ['*'],
];