PHP Velho Oeste 2024

Neue Features

PHP 5.4.0 bietet eine ganze Reihe neuer Features:

  • Unterstützung für Traits wurde hinzugefügt.
  • Die kurze Array-Syntax wurde hinzugefügt, z.B. $a = [1, 2, 3, 4]; oder $a = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => 4];.
  • Das Dereferenzieren von Funktionen, die ein Array zurückgeben, wurde hinzugefügt, z.B. foo()[0].
  • Closures unterstützen nun $this.
  • <?= ist nun immer verfügbar, unabhängig von der short_open_tag php.ini Option.
  • Zugriff auf Klassenmitglieder bei der Instanziierung wurde hinzugefügt, z.B. (new Foo)->bar().
  • Class::{expr}() Syntax wird nun unterstützt.
  • Das binäre Zahlenformat wurde hinzugefügt, z.B. 0b001001101.
  • Parser-Fehlermeldungen und Warnung wegen inkompatibler Argumente wurden verbessert.
  • Die Session Extension kann nun den Upload-Fortschritt von Dateien verfolgen.
  • Ein eingebauter Webserver im CLI-Modus für die Entwicklung.
  • Die GD Extension unterstützt nun Lesen und Schreiben von WebP-Bildern durch imagecreatefromwebp() bzw. imagewebp().
add a note add a note

User Contributed Notes 3 notes

up
28
Nick Garvey
11 years ago
'callable' was implemented as a typehint in 5.4
up
4
Joris Berthelot
5 years ago
PHP 5.4 also allows to use arrays in switch:

<?php

$foo
= 1;
$bar = 2;

switch([
$foo, $bar]) {
    case [
1, 2]:
        echo
'case 1';
        break;
    case [
2, 2]:
        echo
'case 2';
        break;
    case [
3, 4]:
        echo
'case 3';
        break;
}

// Will output  "case 1"
?>
up
9
dave1010 at gmail dot com
11 years ago
As of PHP 5.4, the CLI (using readline) no longer dies on fatal errors (for example calling undefined functions).
To Top