mirror of
https://git.lolcat.ca/lolcat/4get.git
synced 2024-11-14 03:49:48 +01:00
make 'oracles' feature backwards compatible with php 7.4 (#13)
adds implementations of `str_contains` and `str_starts_with` that are used if the functions are not already defined. this should enable 4get to work on both php 7.4 and php 8.* my instance is currently on 7.4.33, and you can see the oracles working here: [calc.php](https://4get.silly.computer/web?s=2%2B4*(2^2)) [encoder.php](https://4get.silly.computer/web?s=md5+hamburger) [numerics.php](https://4get.silly.computer/web?s=0xf0f0f) [time.php](https://4get.silly.computer/web?s=what+is+the+time+right+now+tz%253Aest) Reviewed-on: https://git.lolcat.ca/lolcat/4get/pulls/13 Co-authored-by: cynic <admin@cynic.moe> Co-committed-by: cynic <admin@cynic.moe>
This commit is contained in:
parent
8762d68466
commit
be8546bdf5
2 changed files with 19 additions and 0 deletions
|
@ -21,4 +21,16 @@ abstract class oracle {
|
|||
return "";
|
||||
}
|
||||
}
|
||||
// backwards compatibility
|
||||
if (!function_exists('str_starts_with')) {
|
||||
function str_starts_with($haystack, $needle) {
|
||||
return strncmp($haystack, $needle, strlen($needle)) === 0;;
|
||||
}
|
||||
}
|
||||
if (!function_exists('str_contains')) {
|
||||
function str_contains($haystack, $needle) {
|
||||
return strpos((string)$haystack, (string)$needle) !== false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -84,6 +84,13 @@ class calculator extends oracle {
|
|||
}
|
||||
}
|
||||
|
||||
// no implicit multiplication
|
||||
for ($i = 0; $i < count($tokens) - 1; $i++) {
|
||||
if ($tokens[$i][0] == "n" && $tokens[$i+1] == ["g", "("]) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
//strategy:
|
||||
// traverse to group open (if there is one)
|
||||
// - return to start with the internals
|
||||
|
|
Loading…
Reference in a new issue