function test($a = 1, $b = 2) {
print "a: $a, b: $b";
}
test(b: 5); // Выведет "a: 1, b: 5"
<?php
class Test {}
var_dump(json_decode(json_encode(new Test())));
var_dump(unserialize(serialize(new Test())));
object(stdClass)#1 (0) {
}
object(Test)#1 (0) {
}
<?php
/**/ print (isset($_startTime_) ? 'Execution time: ' . number_format(microtime(true) - $_startTime_, 10) . ' seconds' . "\r\n" : ''); $_startTime_ = microtime(true);
for ($i = 0; $i < 100; $i++)
{
$a = include __DIR__ . '/test2.php';
}
/**/ print (isset($_startTime_) ? 'Execution time: ' . number_format(microtime(true) - $_startTime_, 10) . ' seconds' . "\r\n" : ''); $_startTime_ = microtime(true);
for ($i = 0; $i < 100; $i++)
{
$a = unserialize(file_get_contents(__DIR__ . '/test3.php'));
}
/**/ print (isset($_startTime_) ? 'Execution time: ' . number_format(microtime(true) - $_startTime_, 10) . ' seconds' . "\r\n" : ''); $_startTime_ = microtime(true);
for ($i = 0; $i < 100; $i++)
{
$a = json_decode(file_get_contents(__DIR__ . '/test4.php'));
}
/**/ print (isset($_startTime_) ? 'Execution time: ' . number_format(microtime(true) - $_startTime_, 10) . ' seconds' . "\r\n" : ''); $_startTime_ = microtime(true);
for ($i = 0; $i < 100; $i++)
{
$a = json_decode(file_get_contents(__DIR__ . '/test4.php'), false, 1);
}
/**/ print (isset($_startTime_) ? 'Execution time: ' . number_format(microtime(true) - $_startTime_, 10) . ' seconds' . "\r\n" : ''); $_startTime_ = microtime(true);
Execution time: 0.0024001598 seconds
Execution time: 0.0056669712 seconds
Execution time: 0.0069279671 seconds
Execution time: 0.0025250912 seconds