

PHP 8.4? PHP ??? ?? ???????.
?? ??, ??? ???, ???? ? DOM API, ?? ??, ?? ?? ? ?? ??? ?? ?? ??? ??? ???? ????.
?? PHP 8.4? ?????????!?? ??
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

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
Property Hooks? ????? ?? DocBlock ??? ???? ??? IDE ? ?? ?? ??? ????? ??? ??? ?? ? ??? ?????. ??, ??? ???? ???? getter ?? setter? ????? ??? ???? ??? ?? ??? ??? ?? ?? ?? ??? ?????.
??? ???
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}" ;
}
}

public private(set) string $version = '8.4' ;
public function increment(): void {
[ $major, $minor ] = explode( '.', $this->version );
$minor++;
$this->version = "{$major}.{$minor}" ;
}
}
???? ?? ??? ?? ???? ?? ??? ????? ?? ? ? ???, ??? ???? ??? ???? ?? ??? ???? ?? ??? ???? ??? ????? ???? ?? ? ????.
#[\Deprecated] ????
/**
* @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();

#[\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 ?? ? HTML5 ??
$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)

<<<'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 ??? ?? ??? ?? ?? ?? ??? ?? ? ??? DOM API? DOM ??? ???? ?? ?? ?? ?? ?? ??? ???? ?? ????? ???? ??? ?? ?? ??? ?????.
??? DOM API? DOM ?? ???? ??? ??? ? ????. ??? DOM API? ??? ??? domhtmldocument ? domxmldocument ???? ???? ?? ? ????.
bcmath? ?? API
$num2 = '2';
$result = bcadd($num1, $num2, 5);
echo $result; // '2.12345'
var_dump(bccomp($num1, $num2) > 0); // false

$num1 = new Number('0.12345');
$num2 = new Number('2');
$result = $num1 + $num2;
echo $result; // '2.12345'
var_dump($num1 > $num2); // false
??? BCMATHNUMBER ??? ??? ?? ??? ?? ? ? ?? ?? ?? ? ?? ?? ???? ??????.
? ??? ???? ??? ??? ?????? ????? Echo $ num? ?? ??? ?????? ??? ? ????.
New array_*() functions
foreach ( [ 'dog', 'cat', 'cow', 'duck', 'goose' ] as $value ) {
if ( str_starts_with($value, 'c') ) {
$animal = $value;
break;
}
}
var_dump($animal); // string(3) "cat"

[ 'dog', 'cat', 'cow', 'duck', 'goose' ],
static fn (string $value): bool => str_starts_with($value, 'c'),
);
var_dump($animal); // string(3) "cat"
??? ?? array_find (), array_find_key (), array_any () ? array_all ()? ??? ? ????.
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');

'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? pdoSqlites? ??? ? ????.
new MyClass()->method()????
public function getVersion(): string {
return 'PHP 8.4';
}
}
var_dump(( new PhpVersion())->getVersion());

public function getVersion(): string {
return 'PHP 8.4';
}
}
var_dump(new PhpVersion()->getVersion());
?? ????? ? ??? ?? ? ??? ?? ? ??? ?? ?? ??? ?? ??? ? ? ????.
??? ???, ????? ? ??
- ??? ??? ??.
- IR ??? ??? ???? ? ??? JIT ??.
- ??? request_parse_body () ??.
- 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 () ? dateTimeImutable :: setTimicrosecond () ??.
- new MB_TRIM (), MB_LTRIM (), MB_RTRIM (), MB_UCFIRST () ? MB_LCFIRST () ??.
- ??? pcntl_getcpu (), pcntl_getcpuaffinity (), pcntl_getqos_class (), pcntl_setns () ? pcntl_waitid () ??.
- New ReflectionClassConstant :: isdeprecated (), reflectiongenerator :: isclosed () ? reflectionProperty :: isdynamic () ???.
- ??? http_get_last_response_headers (), http_clear_last_response_headers () ? fpow () ??.
- new xmlreader :: fromstream (), xmlreader :: fomuri (), xmlreader :: fromstring (), xmlwriter :: tostream (), xmlwriter :: touri () ? xmlwriter :: tomemory () ???.
- ??? Grapheme_str_split () ??.
?? ?? ? ?? ???? ??? ??
- IMAP, OCI8, PDO_OCI, and pspell extensions have been unbundled and moved to PECL.
- ?? ??? ??? ??? ?? ?? ??? ?? ? ?? ???? ????.
- ??? ???? _? ???? ?? ?? ? ?? ???? ????.
- ??? ???? 0? ????? ?? ?? ? ?? ???? ????.
- ?? ??? Round ()? ???? ValueError? ?????.
- ?? ??, intl, pdo, ??, spl, sqlite, xmlreader? ??? ??? ?? ???????.
- GMP ???? ?? ?????.
- mysqli_set_charset_dir, mysqli_stmt_attr_prefetch_rows, mysqli_cursor_type_for_update, mysqli_cursor_type_scrollable ? mysqli_type_interval ??? ???????.
- mysqli_ping (), mysqli_kill (), mysqli_refresh () functions, mysqli :: ping (), mysqli :: kill (), mysqli :: refresh () ??? ? mysqli_refresh_* ??? ?? ??????.
- stream_bucket_make_writable () ? stream_bucket_new () ?? stdclass ?? StreamBucket ????? ?????.
- ?? () ?? ??.
- e_strict ??? ? ?? ???? ?????.
PHP 8.4? ?? ????? ??? ?????? ???? ???. Windows Binaries??? ?? ? ???? Windows ? PHP ??. ?? ??? ??? ???? ???? changelog.
??? ?????? ??? PHP ????? ??? ? ????. ??? ??? ??? ??? ?? ???? ?? ?? ??? ???? ??????.