<?php
class A
{
private $private = 0;
public function addPrivate()
{
$this->private++;
}
public function getPrivate()
{
return $this->private;
}
}
class B extends A
{
public $private = 10;
public function addBPrivate($private)
{
$this->private++;
}
public function getPrivate()
{
return $this->private;
}
}
$a = new A();
$a->addPrivate();
var_dump($a->getPrivate());
$b = new B();
$b->addPrivate();
var_dump($b->getPrivate());
$b->addBPrivate();
var_dump($b->getPrivate());
int(1)
int(10)
Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::addBPrivate(), 0 passed in /in/f7KtG on line 40 and exactly 1 expected in /in/f7KtG:22
Stack trace:
#0 /in/f7KtG(40): B->addBPrivate()
#1 {main}
thrown in /in/f7KtG on line 22
Process exited with code 255.
int(1)
int(10)
Warning: Missing argument 1 for B::addBPrivate(), called in /in/f7KtG on line 40 and defined in /in/f7KtG on line 22
int(11)
Output for 5.0.0 - 5.0.5
int(1)
int(10)
Warning: Missing argument 1 for B::addBPrivate() in /in/f7KtG on line 22
int(11)
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/f7KtG on line 5
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/f7KtG on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/f7KtG on line 5
Process exited with code 255.