国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

その他の変更ログ その他の変更ログ

PHP 8.4は、PHP言語(yǔ)の主要な更新です。

プロパティフック、非対稱(chēng)の可視性、更新されたDOM API、パフォーマンスの改善、バグ修正、一般的なクリーンアップなど、多くの新機(jī)能が含まれています。

今すぐPHP 8.4にアップグレードしてください!

プロパティフック

PHP < 8.4
class Locale {
private string $languageCode;
private string $countryCode;

public function __construct ( string $languageCode, string $countryCode )
{
$this->setLanguageCode($languageCode);
$this->setCountryCode($countryCode);
}

public function getLanguageCode(): string {
return $this->languageCode;
}

public function setLanguageCode( string $languageCode ): void {
$this->languageCode = $languageCode;
}

public function getCountryCode(): string {
return $this->countryCode;
}

public function setCountryCode( string $countryCode ): void {
$this->countryCode = strtoupper($countryCode);
}

public function setCombinedCode( string $combinedCode ): void {
[ $languageCode, $countryCode ] = explode( '_', $combinedCode, 2 );
$this->setLanguageCode($languageCode);
$this->setCountryCode($countryCode);
}

public function getCombinedCode(): string {
return \sprintf( "%s_%s", $this->languageCode, $this->countryCode );
}
}

$brazilianPortuguese = new Locale( 'pt', 'br' );

var_dump( $brazilianPortuguese->getCountryCode() ); // BR

var_dump( $brazilianPortuguese->getCombinedCode() ); // pt_BR
PHP 8.4
class Locale {
public string $languageCode;

public string $countryCode {
set ( string $countryCode ) {
$this->countryCode = strtoupper($countryCode);
}
}

public string $combinedCode {
get => \sprintf( "%s_%s", $this->languageCode, $this->countryCode );
set ( string $value ) {
[ $this->languageCode, $this->countryCode ] = explode( '_', $value, 2 );
}
}

public function __construct( string $languageCode, string $countryCode ) {
$this->languageCode = $languageCode;
$this->countryCode = $countryCode;
}
}

$brazilianPortuguese = new Locale( 'pt', 'br' );

var_dump( $brazilianPortuguese->countryCode ); // BR

var_dump( $brazilianPortuguese->combinedCode ); // pt_BR

プロパティフックは、同期が外れる可能性のあるDocblockコメントを書(shū)く必要なく、IDESおよび靜的分析ツールによってネイティブに理解できる計(jì)算プロパティをサポートします。さらに、クラスに一致するゲッターまたはセッターが存在するかどうかを確認(rèn)することなく、値の信頼できる前処理または後処理を許可します。

非対稱(chēng)可視性

PHP < 8.4
class PhpVersion {
private string $version = '8.3' ;

public function getVersion(): string {
return $this->version;
}

public function increment(): void {
[ $major, $minor ] = explode( '.', $this->version );
$minor++;
$this->version = "{$major}.{$minor}" ;
}
}
PHP 8.4
class PhpVersion {
public private(set) string $version = '8.4' ;

public function increment(): void {
[ $major, $minor ] = explode( '.', $this->version );
$minor++;
$this->version = "{$major}.{$minor}" ;
}
}

プロパティに書(shū)き込む範(fàn)囲は、プロパティを読むために範(fàn)囲から獨(dú)立して制御されるようになり、クラスの外側(cè)からの変更を許可することなく、ボイラープレートゲッターメソッドがプロパティの価値を公開(kāi)する必要性を減らします。

#[\Deprecated] 屬性

PHP < 8.4
class PhpVersion {
/**
* @deprecated 8.3 use PhpVersion::getVersion() instead
*/
public function getPhpVersion(): string {
return $this->getVersion();
}

public function getVersion(): string {
return '8.3';
}
}

$phpVersion = new PhpVersion();
// No indication that the method is deprecated.
echo $phpVersion->getPhpVersion();
PHP 8.4
class PhpVersion {
#[\Deprecated(
message: "use PhpVersion::getVersion() instead",
since: "8.4",
)]
public function getPhpVersion(): string {
return $this->getVersion();
}

public function getVersion(): string {
return '8.4';
}
}

$phpVersion = new PhpVersion();
// Deprecated: Method PhpVersion::getPhpVersion() is deprecated since 8.4, use PhpVersion::getVersion() instead
echo $phpVersion->getPhpVersion();

The new #[Deprecated] attribute makes PHP’s existing deprecation mechanism available to user-defined functions, methods, and class constants.

新しいExt-Dom機(jī)能とHTML5サポート

PHP < 8.4
$dom = new DOMDocument();
$dom->loadHTML(
<<<'HTML'
<main>
<article>PHP 8.4 is a feature-rich release!</article>
<article class="featured">PHP 8.4 adds new DOM classes that are spec-compliant, keeping the old ones for compatibility.</article>
</main>
HTML,
LIBXML_NOERROR,
);

$xpath = new DOMXPath($dom);

$node = $xpath->query('.//main/article[not(following-sibling::*)]')[0];

$classes = explode(" ", $node->className); // Simplified

var_dump(in_array("featured", $classes)); // bool(true)
PHP 8.4
$dom = Dom\HTMLDocument::createFromString(
<<<'HTML'
<main>
<article>PHP 8.4 is a feature-rich release!</article>
<article class="featured">PHP 8.4 adds new DOM classes that are spec-compliant, keeping the old ones for compatibility.</article>
</main>
HTML,
LIBXML_NOERROR,
);

$node = $dom->querySelector('main > article:last-child');
var_dump($node->classList->contains("featured")); // bool(true)

HTML5ドキュメントの解析のための標(biāo)準(zhǔn)に準(zhǔn)拠したサポートを含む新しいDOM API、DOM機(jī)能の動(dòng)作におけるいくつかの長(zhǎng)年のコンプライアンスバグを修正し、ドキュメントをより便利にするためのいくつかの機(jī)能を追加します。

新しいDOM APIは、DOM Namespace內(nèi)で使用できます。新しいDom APIを使用したドキュメントは、domhtmldocumentおよびdomxmldocumentクラスを使用して作成できます。

bcmathのオブジェクトAPI

PHP < 8.4
$num1 = '0.12345';
$num2 = '2';
$result = bcadd($num1, $num2, 5);

echo $result; // '2.12345'
var_dump(bccomp($num1, $num2) > 0); // false
PHP 8.4
use BcMath\Number;

$num1 = new Number('0.12345');
$num2 = new Number('2');
$result = $num1 + $num2;

echo $result; // '2.12345'
var_dump($num1 > $num2); // false

任意の精度番號(hào)を使用する際に、新しいbcmathnumberオブジェクトは、オブジェクト指向の使用法と標(biāo)準(zhǔn)の數(shù)學(xué)演算子を有効にします。

これらのオブジェクトは不変であり、弦楽器のインターフェイスを?qū)g裝するため、echo $ numなどの文字列コンテキストで使用できます。

New array_*() functions

PHP < 8.4
$animal = null;
foreach ( [ 'dog', 'cat', 'cow', 'duck', 'goose' ] as $value ) {
if ( str_starts_with($value, 'c') ) {
$animal = $value;
break;
}
}

var_dump($animal); // string(3) "cat"
PHP 8.4
$animal = array_find(
[ 'dog', 'cat', 'cow', 'duck', 'goose' ],
static fn (string $value): bool => str_starts_with($value, 'c'),
);

var_dump($animal); // string(3) "cat"

new Functions array_find()、array_find_key()、array_any()、およびarray_all()が利用可能です。

PDOドライバー固有のサブクラス

PHP < 8.4
$connection = new PDO(
'sqlite:foo.db',
$username,
$password,
); // object(PDO)

$connection->sqliteCreateFunction(
'prepend_php',
static fn ($string) => "PHP {$string}",
);

$connection->query('SELECT prepend_php(version) FROM php');
PHP 8.4
$connection = PDO::connect(
'sqlite:foo.db',
$username,
$password,
); // object(Pdo\Sqlite)

$connection->createFunction(
'prepend_php',
static fn ($string) => "PHP {$string}",
); // Does not exist on a mismatching driver.

$connection->query('SELECT prepend_php(version) FROM php');

新しいサブクラスPDODBLIB、PDOFIREBIRD、PDOMYSQL、PDOODBC、PDOPGSQL、およびPDOSQLITEのPDOが利用可能です。

new MyClass()->method()括弧なし

PHP < 8.4
class PhpVersion {
public function getVersion(): string {
return 'PHP 8.4';
}
}

var_dump(( new PhpVersion())->getVersion());
PHP 8.4
class PhpVersion {
public function getVersion(): string {
return 'PHP 8.4';
}
}

var_dump(new PhpVersion()->getVersion());

新たにインスタンス化されたオブジェクトのプロパティと方法に、括弧內(nèi)の新しい式を包むことなくアクセスできるようになりました。

新しいクラス、インターフェイス、関數(shù)

  • 新しい怠zyなオブジェクト。
  • IRフレームワークに基づく新しいJIT実裝。
  • new request_parse_body()関數(shù)。
  • New bcceil(),>bcdivmod(),bcfloor(), and bcround() functions.
  • New RoundingMode enum for round() with 4 new rounding modes TowardsZero,AwayFromZero, NegativeInfinity,and PositiveInfinity.
  • new DateTime :: CreateFromTimestamp()、DateTime :: getMicroSecond()、DateTime :: SetMicroSecond()、DateTimeImMutable :: createFromTimeStamp()、DateTimeImmutable :: GetMicRoSecond()、およびDateTimeimmutable :: SetMicRoseCond()
  • new MB_TRIM()、MB_LTRIM()、MB_RTRIM()、MB_UCFIRST()、およびMB_LCFIRST()関數(shù)。
  • new PCNTL_GETCPU()、PCNTL_GETCPUAFFINITY()、PCNTL_GETQOS_CLASS()、PCNTL_SETNS()、およびPCNTL_WAITID()関數(shù)。
  • new ReflectionClassConstant :: isDeprecated()、ReflectionGenerator :: ISClosed()、およびReflectionProperty :: isDynamic()メソッド。
  • new http_get_last_response_headers()、http_clear_last_response_headers()、およびfpow()関數(shù)。
  • new xmlreader :: fromstream()、xmlreader :: fromuri()、xmlreader :: fromstring()、xmlwriter :: toStream()、xmlwriter :: touri()、およびxmlwriter :: tomemory()メソッド。
  • new Grapheme_str_split()関數(shù)。

非推奨と下位互換性の中斷

  • IMAP, OCI8, PDO_OCI, and pspell extensions have been unbundled and moved to PECL.
  • 暗黙のうちに無(wú)視可能なパラメータータイプが非推奨になりました。
  • _をクラス名として使用すると、これが非推奨になります。
  • 負(fù)の數(shù)のパワーにゼロを上げることは、今では非推奨になります。
  • 無(wú)効なモードをRound()に渡すと、ValueErrorをスローします。
  • 拡張日、INTL、PDO、リフレクション、SPL、SQLITE、XMLReaderのクラス定數(shù)が現(xiàn)在入力されています。
  • GMPクラスが最終的になりました。
  • mysqli_set_charset_dir、mysqli_stmt_attr_prefetch_rows、mysqli_cursor_type_for_update、mysqli_cursor_type_scrollable、およびmysqli_type_interval定數(shù)が除去されました。
  • mysqli_ping()、mysqli_kill()、mysqli_refresh()functions、mysqli :: ping()、mysqli :: kill()、mysqli :: refresh()メソッド、およびmysqli_refresh_*定數(shù)は非推奨です。
  • stream_bucket_make_writable()およびstream_bucket_new()は、stdclassの代わりにstreambucketのインスタンスを返すようになりました。
  • exit()行動(dòng)の変化。
  • e_strict定數(shù)は非推奨です。
パフォーマンス、構(gòu)文が改善され、型の安全性が向上しました。 今すぐPHP 8.4にアップグレードしてください!

PHP 8.4のソースダウンロードについては、をご覧ください ダウンロード ページ。 Windowsバイナリはにあります Windows用のPHP サイト。変更のリストはに記録されます Changelog。

The 移行ガイド PHPマニュアルで入手できます。新機(jī)能と後方に取得できない変更の詳細(xì)なリストについては、それを參照してください。