本文整理汇总了PHP中Employee::work方法的典型用法代码示例。如果您正苦于以下问题:PHP Employee::work方法的具体用法?PHP Employee::work怎么用?PHP Employee::work使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Employee
的用法示例。
在下文中一共展示了Employee::work方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: work
<?php
class Employee
{
public $name;
public $age;
public $job;
public $salary;
public function work()
{
echo '働いている!';
}
}
$saji = new Employee();
// Employeeクラスのインスタンスを生成
$saji->work();
//インスタンスからメソッドを呼び出す
示例2: Person
include_once "Entities\\Manager.php";
include_once "Entities\\Department.php";
$ivan = new Person("vano", 111);
// $ivan -> id = 111123;
// $ivan -> name = "vano";
echo $ivan->getName() . "\n";
echo $ivan->getId() . "\n";
echo $ivan->__get("name") . "\n";
echo $ivan->__get("id") . "\n";
$ivanSalary = $ivan->__get("salary") . "\n";
$ivanAge = $ivan->age . "\n";
// неявно вызывает функцию __get
echo "ivan has salary :" . $ivanSalary;
echo "ivan has age :" . $ivanAge;
$he = new Employee();
$hisResult = $he->work(true);
echo "Он работал весь день и результат: " . $hisResult . "\n";
$she = new Manager(10000000);
$herSalary = $she->salary;
echo "Она не работала весь день и ее зарплата: " . $herSalary . "\n";
$employees = array();
$department = new Department("IT", $employees, $she);
$she->hire($ivan);
$allEmployees = $department->getEmployees();
printAllEmployees($allEmployees);
$she->hire($he);
$allEmployees = $department->getEmployees();
printAllEmployees($allEmployees);
$she->fire($he);
$allEmployees = $department->getEmployees();
printAllEmployees($allEmployees);
示例3: Employee
<?php
require_once 'Person-class.php';
require_once 'Employee-class.php';
$werknemer = new Employee('Ryan', 'Carsonified');
// Instantie aanmaken van de klasse Employee
// Aangepaste employee klasse
//$werknemer = new Employee('Ryan', 'Carsonified'); // Instantie aanmaken van de klasse Employee
$dialog;
$dialog[] = 'De werknemer ' . $werknemer->getName() . ' werkt bij ' . $werknemer->getCompany() . ' en heeft ' . $werknemer->getSavings() . '€ op zijn spaarboekje staan.';
$dialog[] = $werknemer->work(8);
$dialog[] = 'De werknemer ' . $werknemer->getName() . ' heeft ' . $werknemer->getSavings() . '€ op zijn spaarboekje staan.';
// Method uit de parent class
require_once 'voorbeeld-classes-inheritance-parent-view.php';
示例4: Task
$t9 = new Task("Task 9", 3);
$t10 = new Task("Task 10", 2);
$t11 = new Task("Task 11", 2);
$t12 = new Task("Task 12", 2);
$allWork = new AllWork();
$allWork->addTask($t1);
$allWork->addTask($t2);
$allWork->addTask($t3);
$allWork->addTask($t4);
$allWork->addTask($t5);
$allWork->addTask($t6);
$allWork->addTask($t7);
$allWork->addTask($t8);
$allWork->addTask($t9);
$allWork->addTask($t10);
$allWork->addTask($t11);
$allWork->addTask($t12);
$e1 = new Employee("Ivan", $allWork);
$e2 = new Employee("Niki", $allWork);
$e3 = new Employee("Tina", $allWork);
$moreWork1 = false;
$moreWork2 = false;
$moreWork3 = false;
$days = 1;
while (!$moreWork1 || !$moreWork2 || !$moreWork3) {
echo 'Start working day number ' . $days . PHP_EOL;
$days++;
$moreWork1 = $e1->work();
$moreWork2 = $e2->work();
$moreWork3 = $e3->work();
}