2021年7月14日解決済み

function の引数に Post 型を指定するのはなぜですか?

ユーザー
$posts[0] = new Post('hello');
$posts[1] = new Post('hello again');
$posts[2] = new SponsoredPost('hello hello', 'dotinstall');

function processPost(Post $post)
{
  $post->show();

のところの Post 型をやる理由がわかりません。

スタッフ

この回答を見るにはプレミアムプランへの登録が必要です

プレミアムプランとは?