我的代码有问题:
declare(strict_types=1);
class TextModifications
{
static public function readValue(string $string): string
{
return $purifier->purify($string);
}
static public function saveValue(string $string): string
{
return $string;
}
}
$TextModifications = new TextModifications();
$TextModifications->saveValue($_POST["login"])
Run Code Online (Sandbox Code Playgroud)
我有错误: 致命错误:未捕获的TypeError:传递给TextModifications的参数1 :: saveValue()必须是字符串类型,给定null,在第21行的/Applications/XAMPP/xamppfiles/htdocs/1.php中调用并在/Applications/XAMPP/xamppfiles/htdocs/1.php:11堆栈跟踪:#0 /Applications/XAMPP/xamppfiles/htdocs/1.php(21):TextModifications :: saveValue(NULL)#1 {main}抛出/第11行的Applications/XAMPP/xamppfiles/htdocs/1.php
我有PHP 7.2.
有谁知道如何解决这个问题?