From release 9.8 and on, Scriptcase is also compatible with PHP 8.1.
$result = $aa != "" ? $xxx : isset($bb) && $bb != "" ? $zzz : "";
From PHP 8 and on:
if ($aa != "") {
$result = $xxx;
} elseif (isset($bb) && $bb != "") {
$result = $zzz;
} else {
$result = "";
}
$array = [1, 2];
echo $array[1]; // prints 2
echo $array{1}; // also prints 2
$string = "foo";
echo $string[0]; // prints "f"
echo $string{0}; // also prints "f"
From PHP 8 and on:
$array = [1, 2];
echo $array[1]; // prints 2
echo $array{1}; // prints the error: Deprecated: Array and string offset access syntax with curly braces is deprecated...
$string = "foo";
echo $string[0]; // prints "f"
echo $string{0}; // prints the error: Deprecated: Array and string offset access syntax with curly braces is deprecated...
function foo($param_optional = null, $param_required) {
// ^^ optional parameter , ^^ required parameter
}
Deprecated: Required parameter $param_required follows optional parameter $param_optional in ... on line ...
$b = "";
$a = $b + 2;
From PHP 8 and on, it is necessary to test if the value of $b is a numeric string or a number, before performing the operation:$a = is_numeric($b) ? $b + 2 : 2;
I.e 2:
if (!is_numeric($b)) {
$b = 0;
}
$a = $b + 2;
$a = isset($b) ? $b + 2 : 2;
$result = "";
$tab = array(0=>array('tp'=>1,'vl'=>'aaa'),
1=>array('tp'=>2,'vl'=>'bbb'),
2=>array('tp'=>3,'vl'=>'ccc'));
Before PHP 8:
while (list ($key, $val) = each($tab)) {
$result .= $tab[$key]["vl"];
}
From PHP 8, using foreach():
foreach ($tab as $key => $val) {
$result .= $tab[$key]["vl"];
}
if (array_key_exists('index', $array1)) {
// codigo
}
From PHP 8 and on:
if (isset($array1['index'])) {
// codigo
}
echo money_format("%.2n", 1234.56);
From PHP 8 and on:
$currencyObject = new NumberFormatter("pt-BR", NumberFormatter::CURRENCY);
echo $currencyObject->format(1234.56);
$string = 'O rato roeu a roupa';
echo mb_strrpos($string, 'roeu', 'UTF-8');
From PHP 8 and on:
$string = 'O rato roeu a roupa';
echo mb_strrpos($string, 'roeu', 0, 'UTF-8');