public static function foo() { $foo = new d(); d::$x = $foo; unset($foo); echo "Foo: "; echo d::$x = "main"; echo "\n"; var_dump(d::$x); }
public function action_validate() { $post = array('email' => '*****@*****.**', 'password' => 'qwn', 'username' => 'rhr'); $users = Model::factory('v1_users'); $valid = $users->validate($post); if ($valid->check()) { $user = $users->add($post); } else { d::v($valid->errors('register')); } }
public static function _dump($value) { self::$silent = true; echo "\n<!--\n"; $args = func_get_args(); if (count($args) > 1) { foreach ($args as $arg) { self::dodump($arg, true, false, true); } } else { self::dodump($args, true, false, true); } echo "\n-->\n"; }
function __construct() { a::y(); b::y(); c::y(); d::y(); a::$x; b::$x; c::$x; d::$x; a::$xpr; b::$xpr; c::$xpr; d::$xpr; }
/** * Логи в файл * * @param string $message * Сообщение * * @param int $ident_change * Изменение отступа */ public static function log_file($message, $ident_change = 0) { static $ident = 0; if (!defined('SN_DEBUG_LOG')) { return; } if (self::$log_file_handler === null) { self::$log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+'); @fwrite(self::$log_file_handler, "\r\n\r\n"); } $ident_change < 0 ? $ident += $ident_change * 2 : false; if (self::$log_file_handler) { @fwrite(self::$log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n"); } $ident_change > 0 ? $ident += $ident_change * 2 : false; }
} interface c extends a, b { public function baz(); } class d implements c { public function foo($a) { if (!isset($a)) { return "foo"; } else { return $a; } } public function bar() { return "bar"; } public function baz() { return "baz"; } } $d = new d(); echo $d->foo("tes"); echo "<br>"; echo $d->bar(); echo "<br>"; echo $d->baz(); echo "<br>";
{ public $a = 'a'; private $b = 'b'; protected $c = 'c'; function t2($y) { foreach ($this as $k => $v) { var_dump($v); } foreach ($y as $k => $v) { var_dump($v); } foreach ($y as $k => $v) { var_dump($v); } } } $x = new d(); $x->surprise = 1; $y = new d(); $y->shock = 2; echo "t2\n"; $x->t2($y); echo "t1\n"; $x->t1($y); $z = new c(); echo "t12\n"; $z->t1($x); foreach ($x as $k => $v) { var_dump($v); }
public function action_api() { $data = array('email' => '*****@*****.**', 'password' => 'qweqwe'); $data = $this->api->action('v1/auth/join')->params($data)->post(); d::v($data); }
$foo++; echo $foo; } static function sf() { static $foo = 0; $foo++; echo $foo; } } class d extends c { public $q = 30; } $x = new c(); $x->x(); $x->y(); $x->y(); $x->y(); $x->y(); $x = new d(); $x->x(); $x->y(); $x->y(); $x->y(); c::sf(); c::sf(); c::sf(); d::sf(); d::sf(); d::sf();
function a(b $c) { if (false == d::e($f)) { false; } }
static $name = 10; static function name() { return 11; } } // fully qualified names echo \foo\bar\qux\c::$property; echo \foo\bar\qux\c::CONSTANT; echo \foo\bar\qux\c::method(); use foo\bar; // qualified names echo bar\qux\c::$property; echo bar\qux\c::CONSTANT; echo bar\qux\c::method(); echo bar\baz\c::$property; echo bar\baz\c::CONSTANT; echo bar\baz\c::method(); // aliases use foo\bar\qux\c; echo c::$property; echo c::CONSTANT; echo c::method(); // not-qualified names echo d::$property; echo d::CONSTANT; echo d::method(); // property vs method with the same name echo f::$name; echo f::name(); }
public $cpb1 = 1; public $cpb2 = 2; } trait c1 { use b; public $cpc11 = 1; } trait c2 { use a; public $cpc21 = 1; } class d { use c1, c2; public $cpd1 = 1; public function x() { $this->cpa1; $this->cpa2; $this->cpb1; $this->cpb2; $this->cpc11; $this->cpc21; $this->cpd1; $this->cpe1; } } $d = new d(); $d->x();