1

Is there any difference between this function in PHP 7.4?

public function foo(string $argumentThatCanBeNull = null) {}

public function bar(?string $argumentThatCanBeNull = null) {}
Simo Pelle
  • 141
  • 1
  • 11

1 Answers1

1

There is no difference as string is nullable by default.

Btw, this was introduced in PHP 7.1: https://www.php.net/manual/en/migration71.new-features.php

Ziarek
  • 679
  • 6
  • 14