PHP 8.5.0 Alpha 2 available for testing

Voting

: max(eight, three)?
(Example: nine)

The Note You're Voting On

thanhn2001 at gmail dot com
14 years ago
PHP prevents interface a contant to be overridden by a class/interface that DIRECTLY inherits it. However, further inheritance allows it. That means that interface constants are not final as mentioned in a previous comment. Is this a bug or a feature?

<?php

interface a
{
const
b = 'Interface constant';
}

// Prints: Interface constant
echo a::b;

class
b implements a
{
}

// This works!!!
class c extends b
{
const
b = 'Class constant';
}

echo
c::b;
?>

<< Back to user notes page

To Top