<?php class Employee { public $id; public $name; public $city; public $salary; public function __construct($id, $name, $city, $salary) { $this->id = $id; $this->name = $name; $this->city = $city; $this->salary = $salary; } } $employees = [ new Employee(1, "Dór Tamás", "Szeged", 2875000), new Employee(2, "Ber Ferenc", "Szolnok", 2375000) ]; print_r($employees);
Futtatás:
php -S localhost:8000 -t .
class Employee { public $id; public $name; public $city; public $salary; public function __construct($id, $name, $city, $salary) { $this->id = $id; $this->name = $name; $this->city = $city; $this->salary = $salary; } } class EmployeeController extends Controller { public function getEmployees() { $employees = [ new Employee(1, "Dór Tamás", "Szeged", 2875000), new Employee(2, "Ber Ferenc", "Szolnok", 2375000) ]; return view('home')->with('employees', $employees); } }