LoginSignup
0

More than 1 year has passed since last update.

【PHP】PHPの関数の型の指定(引数)

Last updated at Posted at 2022-08-15

コード

<?php
function func1(array $array) {
  return $array[0];
}
echo func1(['a','b','c']),PHP_EOL;


function func2(int $num){
  return $num + 1;
}
echo func2(9),PHP_EOL;


function func4(string $string) {
  return $string.':文字列';
}
echo func4('a'),PHP_EOL;

結果

a
10
a:文字列

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0