Vikast Vikast - 1 year ago 156
PHP Question

Colon after method declaration?

public function getRecords(int $id): array;

Hi, can someone tell me what colon is doing here, in this method declaration inside PHP interface? Is this PHP 7 syntax and what array is meaning here? Method must return array or something else?

Answer Source

Yes its new syntax introduced in PHP 7 to declare the method returns an array.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download