Add optional $return = false parameter to the csrf function

This commit is contained in:
slawkens
2024-01-30 22:40:40 +01:00
parent 670812772d
commit 6494bd2c0c
4 changed files with 17 additions and 11 deletions

View File

@@ -27,8 +27,14 @@ class CsrfToken
* @static true
* @return void
**/
public static function create(): void {
echo '<input type="hidden" name="csrf_token" value="' . self::get() . '" />';
public static function create(bool $return = false): string {
$input = '<input type="hidden" name="csrf_token" value="' . self::get() . '" />';
if ($return) {
return $input;
}
echo $input;
return '';
}
/**