I have the following code and I am using php 5.5.6
product.php
class product {
const STATUS = status;
function __construct(){}
public function printStatus($status){
echo $status;
}
}
final class status {
const BROKEN = "br";
const AVAILABLE = "av";
}
index.php
include("product.php");
$pr = new product();
$st = product::STATUS;
$pr->printStatus($st::BROKEN);
The above code gives as an output br
, which is the expected
index2.php
include("product.php");
$pr = new product();
$pr->printStatus(product::STATUS::BROKEN);
The above code gives the following error Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) in ...
which means that line $pr->printStatus(product::STATUS::BROKEN);
Does anyone know why this is happening? Is there a php limitation?