Compare commits
3 Commits
114ee6f42a
...
72a762b8e1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72a762b8e1 | ||
|
|
faba9761a2 | ||
|
|
3d420909e0 |
37
wap/php-datatypes/README.md
Normal file
37
wap/php-datatypes/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# **PHP-datatypes**
|
||||
|
||||
## Úvod
|
||||
|
||||
Udelal jsem nejaky testy datatypu, jestli se datatyp nejakým způsobem změní.
|
||||
|
||||
|
||||
## PHP 8.2.1 Results
|
||||
|In datatype |In |Out datatype|Out |
|
||||
|------|-------------------|------|-------------------|
|
||||
|int |10 |int |10 |
|
||||
|int |2 |int |2 |
|
||||
|int |10000 |int |10000 |
|
||||
|int |10 |string|10 |
|
||||
|int |2 |string|2 |
|
||||
|int |10000 |string|10000 |
|
||||
|int |10 |float |10 |
|
||||
|int |2 |float |2 |
|
||||
|int |10000 |float |10000 |
|
||||
|string|asda |int |ERROR |
|
||||
|string|saaaaaaa |int |ERROR |
|
||||
|string|ssae2w2fjkloiuhygfd|int |ERROR |
|
||||
|string|asda |string|asda |
|
||||
|string|saaaaaaa |string|saaaaaaa |
|
||||
|string|ssae2w2fjkloiuhygfd|string|ssae2w2fjkloiuhygfd|
|
||||
|string|asda |float |ERROR |
|
||||
|string|saaaaaaa |float |ERROR |
|
||||
|string|ssae2w2fjkloiuhygfd|float |ERROR |
|
||||
|float |102 |int |102 |
|
||||
|float |2.0E-7 |int |0 |
|
||||
|float |100 |int |100 |
|
||||
|float |102 |string|102 |
|
||||
|float |2.0E-7 |string|2.0E-7 |
|
||||
|float |100 |string|100 |
|
||||
|float |102 |float |102 |
|
||||
|float |2.0E-7 |float |2.0E-7 |
|
||||
|float |100 |float |100 |
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
$EXECUTABLE = "php";
|
||||
|
||||
$datatypes = ["int", "string", "float"];
|
||||
$testreturns = [
|
||||
[10, 2, 10000],
|
||||
@@ -6,27 +9,36 @@ $testreturns = [
|
||||
[102, 0.0000002, 100, 00, 12315, 1231698]
|
||||
];
|
||||
|
||||
|
||||
$results = array();
|
||||
$run = 0;
|
||||
for ($i = 0; $i < sizeof($datatypes); $i++) {
|
||||
for ($p = 0; $p < sizeof($datatypes); $p++) {
|
||||
for ($k = 0; $k < sizeof($testreturns); $k++) {
|
||||
if ($datatypes[$i] == "string"){
|
||||
$func = 'function test('.$datatypes[$i].' $input = "'.$testreturns[$i][$k].'"): '.$datatypes[$p].' { return $input; } try { return test(); } catch (Exception $e) { return "Exception";}';
|
||||
$func = '<?php function test('.$datatypes[$i].' $input = "'.$testreturns[$i][$k].'"): '.$datatypes[$p].' { return $input; } echo test();';
|
||||
} else {
|
||||
$func = 'function test('.$datatypes[$i].' $input = '.$testreturns[$i][$k].'): '.$datatypes[$p].' { return $input; } try { return test(); } catch (Exception $e) { return "Exception";}';
|
||||
$func = '<?php function test('.$datatypes[$i].' $input = '.$testreturns[$i][$k].'): '.$datatypes[$p].' { return $input; } echo test();';
|
||||
}
|
||||
var_dump(eval($func));
|
||||
|
||||
|
||||
$file = fopen("test.php", "w");
|
||||
fwrite($file, $func);
|
||||
fclose($file);
|
||||
|
||||
//var_dump($func);
|
||||
$results[$run]["input_datatype"] = var_export($datatypes[$i], true);
|
||||
$results[$run]["input"] = var_export($testreturns[$i][$k], true);
|
||||
$results[$run]["output_datatype"] = var_export($datatypes[$p], true);
|
||||
$results[$run]["output"] = var_export(shell_exec($EXECUTABLE." -f test.php"), true);
|
||||
|
||||
$run++;
|
||||
// echo $func;
|
||||
}
|
||||
}
|
||||
}
|
||||
var_dump($results);
|
||||
|
||||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
// echo $e;
|
||||
$file = fopen("results.csv", "w");
|
||||
for($i = 0; $i < sizeof($results); $i++) {
|
||||
fwrite($file, $results[$i]["input_datatype"].";".$results[$i]["input"].";".$results[$i]["output_datatype"].";".$results[$i]["output"]."\n");
|
||||
}
|
||||
fclose($file);
|
||||
Reference in New Issue
Block a user