@anonymous/

StingyLargeState

PHP (Legacy)

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.272007195738724","path":"main.php","file":{"path":"main.php","content":{"asEncoding":{"base64":"PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwoKJGlucHV0ID0gJzI0Mys2NzQzLTc4KjIqMC41PSc7CiRpbnB1dExlbmdodCA9IG1iX3N0cmxlbigkaW5wdXQpOwoKJG51bWJlciA9IDA7CiRyZXN1bHQgPSAwOwokb3AgPSAnJzsKCmlmIChwcmVnX21hdGNoKCd+LzB+JywgJGlucHV0KSkgewoJZWNobyAi0J3QsCDQvdC+0LvRjCDQtNC10LvQuNGC0Ywg0L3QtdC70YzQt9GPIVxuIjsKCWV4aXQoKTsKfQoKZm9yICgkaT0wOyAkaSA8ICRpbnB1dExlbmdodDsgJGkrKykgeyAKCSRjaGFyID0gbWJfc3Vic3RyKCRpbnB1dCwgJGksIDEpOwoJaWYgKCRjaGFyID09ICcqJyB8fCAkY2hhciA9PSAnKycgfHwgJGNoYXIgPT0gJy0nIHx8ICRjaGFyID09ICc9JyB8fCAkY2hhciA9PSAnLycpIHsKCQllY2hvICJvcCA9IFt7JG9wfV0sIHJlc3VsdCA9IFt7JHJlc3VsdH1dLCBudW1iZXIgPSBbeyRudW1iZXJ9XSwgY2hhciA9IFt7JGNoYXJ9XVxuIjsKCQlpZiAoIWVtcHR5KCRvcCkpIHsKCQkJc3dpdGNoICgkb3ApIHsKCQkJCQljYXNlICcqJzoKCQkJCQkJJHJlc3VsdCA9ICRyZXN1bHQgKiAkbnVtYmVyOwoJCQkJCQlicmVhazsKCQkJCQljYXNlICcrJzoKCQkJCQkJJHJlc3VsdCA9ICRyZXN1bHQgKyAkbnVtYmVyOwoJCQkJCQlicmVhazsKCQkJCQljYXNlICctJzoKCQkJCQkJJHJlc3VsdCA9ICRyZXN1bHQgLSAkbnVtYmVyOwoJCQkJCQlicmVhazsKCQkJCQljYXNlICcvJzoKCQkJCQkJJHJlc3VsdCA9ICRyZXN1bHQgLyAkbnVtYmVyOwoJCQkJfQkKCQl9IGVsc2UgewoJCQkkcmVzdWx0ID0gJG51bWJlcjsKCQl9CgkJJG51bWJlciA9IDA7CgkJJG9wID0gJGNoYXI7Cgl9CgllbHNlaWYgKGlzX251bWVyaWMoJGNoYXIpKSB7CgkJJG51bWJlciA9IGZsb2F0dmFsKCRudW1iZXIgLiAkY2hhcik7Cgl9IGVsc2VpZiAoJGNoYXIgPT0gJy4nKSB7CgkJJG51bWJlciA9ICRudW1iZXIgLiAkY2hhcjsKCX0gZWxzZSB7CgkJZWNobyAi0J3QtdCy0LXRgNC90YvQuSDRgdC40LzQstC+0Ls6ICd7JGNoYXJ9J1xuIjsKCX0KfQplY2hvICLQntGC0LLQtdGCOiB7JGlucHV0fXskcmVzdWx0fVxuIjsKPz4="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php

error_reporting(-1);
mb_internal_encoding('utf-8');

$input = '243+6743-78*2*0.5=';
$inputLenght = mb_strlen($input);

$number = 0;
$result = 0;
$op = '';

if (preg_match('~/0~', $input)) {
	echo "На ноль делить нельзя!\n";
	exit();
}

for ($i=0; $i < $inputLenght; $i++) { 
	$char = mb_substr($input, $i, 1);
	if ($char == '*' || $char == '+' || $char == '-' || $char == '=' || $char == '/') {
		echo "op = [{$op}], result = [{$result}], number = [{$number}], char = [{$char}]\n";
		if (!empty($op)) {
			switch ($op) {
					case '*':
						$result = $result * $number;
						break;
					case '+':
						$result = $result + $number;
						break;
					case '-':
						$result = $result - $number;
						break;
					case '/':
						$result = $result / $number;
				}	
		} else {
			$result = $number;
		}
		$number = 0;
		$op = $char;
	}
	elseif (is_numeric($char)) {
		$number = floatval($number . $char);
	} elseif ($char == '.') {
		$number = $number . $char;
	} else {
		echo "Неверный символ: '{$char}'\n";
	}
}
echo "Ответ: {$input}{$result}\n";
?>
PHP 7.0.8 (Legacy: use the following for new features: Command-line PHP: https://repl.it/languages/php_cli PHP Web Server: https://repl.it/languages/php7