This commit is contained in:
parent
dd774be005
commit
08296110fb
|
@ -1,14 +1,15 @@
|
|||
class Program {
|
||||
|
||||
private function num2Roman(int $num) {
|
||||
$n = intval($num);
|
||||
$result = '';
|
||||
$lookup = array('M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400,
|
||||
int $n = intval($num);
|
||||
int $result = '';
|
||||
mixed $lookup = array('M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400,
|
||||
'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40,
|
||||
'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1);
|
||||
|
||||
int $matches;
|
||||
foreach($lookup as $roman => $value) {
|
||||
$matches = intval($n / $value);
|
||||
$matches = intval($n / $value);
|
||||
$result += str_repeat($roman, $matches);
|
||||
$n = $n % $value;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ class Program {
|
|||
}
|
||||
|
||||
function a(string $p) {
|
||||
$backtrace = debug_backtrace();
|
||||
mixed $backtrace = debug_backtrace();
|
||||
if(isset($backtrace[0]['args'])) {
|
||||
var_export($backtrace[0]['args']);
|
||||
} else {
|
||||
|
|
|
@ -24,9 +24,9 @@ final class Test {
|
|||
|
||||
final class Program {
|
||||
public function main() {
|
||||
$testA = Test::getInstance();
|
||||
object $testA = Test::getInstance();
|
||||
$testA->set(5);
|
||||
$testB = Test::getInstance();
|
||||
object $testB = Test::getInstance();
|
||||
var_dump($testB->get());
|
||||
}
|
||||
} /* class */
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class Program {
|
||||
|
||||
function main() {
|
||||
mixed $foo;
|
||||
$foo = '0';
|
||||
var_dump($foo);
|
||||
$foo += 2;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
class Unicode {
|
||||
|
||||
public function unicon(string $str, bool $to_uni = true) {
|
||||
$cp = array('А' => 'А', 'а' => 'а',
|
||||
mixed $cpp;
|
||||
mixed $cp = array('А' => 'А', 'а' => 'а',
|
||||
"Б" => "Б", "б" => "б",
|
||||
"В" => "В", "в" => "в",
|
||||
"Г" => "Г", "г" => "г",
|
||||
|
@ -50,7 +51,7 @@ class Unicode {
|
|||
final class Program {
|
||||
|
||||
public function main() {
|
||||
$unicode = new Unicode();
|
||||
object $unicode = new Unicode();
|
||||
var_dump($unicode->unicon("ИфйжБЦ"));
|
||||
}
|
||||
|
||||
|
|
|
@ -13,11 +13,11 @@ class Program {
|
|||
}
|
||||
|
||||
private function isUTF8(string $str) {
|
||||
$b = 0;
|
||||
$c = 0;
|
||||
$bits = 0;
|
||||
$len = strlen($str);
|
||||
for($i = 0; $i < $len; $i++) {
|
||||
int $b = 0;
|
||||
int $c = 0;
|
||||
int $bits = 0;
|
||||
int $len = strlen($str);
|
||||
for(int $i = 0; $i < $len; $i++) {
|
||||
$c = ord($str[$i]);
|
||||
if($c >= 128) {
|
||||
if(($c >= 254)) return false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user