|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-01-15 11:45 UTC] nikic@php.net
-Status: Open
+Status: Duplicate
[2018-01-15 11:45 UTC] nikic@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 12:00:01 2025 UTC |
Description: ------------ The use of a constant as a value results in an error. The direct contact of the string not: ... public static $staticvar = "Hello World"; .... Test script: --------------- <?php namespace { const HELLO_WORLD = "Hello World"; trait TraitParent { public static $staticvar = HELLO_WORLD; public static function test() { return self::$staticvar; } } trait TraitChild { use TraitParent; } Class ClassWhitChildTrait { use TraitChild; } Class ClassWhitOverideChildTrait extends ClassWhitChildTrait { use TraitParent; } echo ClassWhitChildTrait::test() . PHP_EOL; echo ClassWhitOverideChildTrait::test(); }