PHP 7 非推奨機能

PHP 7 の新機能


PHP4 スタイルのコンストラクタ

PHP4 では、クラス内の関数はクラス名と同じ名前にすることができましたが、この機能は PHP7 で非推奨となり、E_DEPRECATED エラーが発行されます。メソッド名がクラス名と同じで、クラスが名前空間にない場合、かつ PHP5 のコンストラクタ(__construct)が存在しない場合に、E_DEPRECATED エラーが発生します。

例

例

<?php
class A {
   function
A() {
      print(
'Style Constructor');
   }
}
?>

上記のプログラムを実行すると、出力結果は次のようになります。

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in...

非静的メソッドの静的呼び出し

非静的メソッドの静的呼び出しは、もはやサポートされません:

例

例

<?php
class A {
   function
b() {
      print(
'Non-static call');
   }
}
A::b();
?>

上記のプログラムを実行すると、出力結果は次のようになります。

Deprecated: Non-static method A::b() should not be called statically in...
Non-static call

password_hash() の salt オプション

関数の salt は開発者が提供する必要がなくなりました。関数内部にはデフォルトで salt 機能が組み込まれており、開発者が salt 値を提供する必要はありません。


capture_session_meta SSL コンテキストオプション

"capture_session_meta" SSL コンテキストオプションは非推奨となりました。ストリームリソース上でアクティブな暗号化関連のメタデータは、stream_get_meta_data() の戻り値からアクセスできます。


PHP 7 の新機能

その他の拡張機能