<?php spl_autoload_register('AutoLoader'); function AutoLoader($classname) { $class = str_replace('\\', DIRECTORY_SEPARATOR, $classname); require_once 'vendor/' . $class . '.php'; } use Academy\Employee; $employee = new Employee('imie', 'nazwisko', '30', 'm', '100', '5'); echo $employee->display(); print_r((array) $employee);
<?php /** * Created by PhpStorm. * User: Przemek * Date: 2015-10-17 * Time: 12:01 */ error_reporting(E_ALL); ini_set('display_errors', 1); spl_autoload_register('AutoLoader'); function AutoLoader($className) { $class = str_replace('\\', DIRECTORY_SEPARATOR, $className); require_once 'vendor/' . $class . '.php'; } use Academy\Employee; $worker1 = new Employee('Przemek', 'Ptasinski', '29', 3000, Employee::GENDER_MALE); $worker2 = new Employee('Asia', 'Ptasinska', '29', 300, Employee::GENDER_FEMALE); echo $worker1->hello(); echo $worker2->display();
<?php //ten kod włącza wyświetlanie błędów, jeśli nie jest włączone error_reporting(E_ALL); ini_set('display_errors', 1); //poniższe wyłączamy, bo zastosujemy autoloadera //require_once 'vendor/Employee.php'; spl_autoload_register('AutoLoader'); function AutoLoader($className) { $class = str_replace('\\', DIRECTORY_SEPARATOR, $className); require_once 'vendor/' . $class . '.php'; } use academy\Employee; $john = new Employee("John", "Smith", 22, 3999); $jane = new Employee("Jane", "Kowalski", 28, 2999, Employee::GENDER_FEMALE); echo $john->hello(); echo "to jest index"; echo '</br>'; $john->setSalary(1000)->setName('Mike'); echo $john->hello();
<?php error_reporting(E_ALL); ini_set('display_errors', 1); spl_autoload_register('AutoLoader'); function AutoLoader($className) { $class = str_replace('\\', DIRECTORY_SEPARATOR, $className); require_once 'vendor/' . $class . '.php'; } use Academy\Employee; // $datetime = new \DateTime(); $john = new Employee("John", "Smith", 22, 2000); $jane = new Employee("Jane", "Smith", 22, 3000, Employee::GENDER_FEMALE); echo $john->hello(); echo "<br />"; $john->setName("Mike")->setSalary(5000); echo $john->hello();
<?php //komentarz do sprawdzenia działanie gita error_reporting(E_ALL); ini_set('display_errors', 1); //require_once 'vendor/Employee.php'; spl_autoload_register('Autoloader'); function Autoloader($className) { $class = str_replace('\\', DIRECTORY_SEPARATOR, $className); require_once 'vendor/' . $class . '.php'; } use Academy\Employee; $john = new Employee("john", "smith", 22, "f"); $jane = new Employee("jane", "smith", 23, "m"); echo $john->hello();
<?php spl_autoload_register('AutoLoader'); function AutoLoader($className) { $class = str_replace('\\', DIRECTORY_SEPARATOR, $className); require_once 'vendor/' . $class . '.php'; } echo "<h1>Szkolenie PHP - 17.10.2015</h1>"; //require_once 'vendor/Employee.php'; use Academy\Employee; //Informujemy że Datetime pochodzi z głównej przestrzeni nazw $datetime = new \DateTime(); $kuba = new Employee("Jakub", "Anckiewicz", "32", "5000"); $monika = new Employee("Monika", "Anckiewicz", "30", "4000", Employee::GENDER_FEMALE); echo $kuba->hello(); $kuba->setSurname("Ancek")->setSalary(6000); echo "<br />"; echo "Pensja roczna: " . $kuba->getSalaryYear(); echo "<br />"; echo $kuba->hello();