Si ca de obicei, o noua versiune de php.
Ce s-a reparat, modificat, adaugat, mai jos
Ca o paranteza, observ ca un conational a reparat ceva pe acolo
Please DO NOT use this version in production, it is an early test version.
Si ca de obicei, o noua versiune de php.
Ce s-a reparat, modificat, adaugat, mai jos
Ca o paranteza, observ ca un conational a reparat ceva pe acolo
Please DO NOT use this version in production, it is an early test version.
Cand solutia magica ce rezolva cele mai grave probleme ale programatorilor, cauzeaza probleme
https://www.php.net/archive/2019.php#2019-07-25-1
Primul beta pt php 7.4
Please DO NOT use this version in production, it is an early test version.
Si s-a lansat oficial
https://www.php.net/index.php#id2019-11-28-1
@iamntz have fun cu arrow functions
Am pregatit si niste exemple
<?php
require 'Demo.php';
echo "Arrow function - array_map" . PHP_EOL;
$factor = 10;
$nums = array_map(fn($n) => $n * $factor, [1, 2, 3, 4]);
print_r($nums);
echo "--------------------------" . PHP_EOL;
echo "Unpacking inside arrays aka spread operator" . PHP_EOL;
$parts = ['apple', 'pear'];
$fruits = ['banana', 'orange', ...$parts, 'watermelon'];
print_r($fruits);
echo "--------------------------" . PHP_EOL;
$demo = new User();
$demo->setId("1")
->setName("Cosmin");
echo $demo->getName();
echo PHP_EOL;
echo "Arrow function - array_filter" . PHP_EOL;
$numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
$evens = array_filter($numbers, fn($n) => $n % 2 == 0);
print_r($evens);
echo "Expression" . PHP_EOL;
$mul2 = fn($x) => $x * 2;
echo $mul2(3);
Demo.php
<?php
class User {
public int $id;
public string $name;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
* @return User
*/
public function setId(int $id): User
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
* @return User
*/
public function setName(string $name): User
{
$this->name = $name;
return $this;
}
}