LoginSignup
7
7

More than 5 years have passed since last update.

PHP7調査(17)エラーメッセージ中のlong/doubleをinteger/floatに統一した

Last updated at Posted at 2015-04-13

PHP7から、エラーメッセージが少しだけわかりやすくなりました。

<?php
date("c", "foo");

このコードをPHP5で実行すると次のようなエラーが表示されます。

PHP Warning:  date() expects parameter 2 to be long, string given in Command line code on line 1

第2引数はlong型だけどstring型が渡されたという、一見すると普通の内容です。しかし、「long型って何?」というのが多くのPHPユーザーの反応ではないでしょうか。筆者の知る限り、PHPマニュアルのどこにもlong型という表記は登場しません。

混乱のもとなので、PHP7ではlongという表記が全てintegerに修正されました。また、doubleという表記もfloatに統一されました。

そんなわけで、PHP7で上のコードを実行すると次のようなエラーが表示されます。

PHP Warning:  date() expects parameter 2 to be integer, string given in Command line code on line 1

すごい!わかりやすい!!!

参照

7
7
0

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
7
7