|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-11-06 12:46 UTC] nanne at huiges dot nl
Description: ------------ --- From manual page: http://www.php.net/reserved.keywords --- The keyword 'self' is not featured in the list of reserved keywords, but it should be. Test script: --------------- <?php class self{ } Expected result: ---------------- The result "implied" by the manual is that this would work. (Not that I say the actual _expected_ result is empty by the way, this is obviously not a bug in code, but a bug in the manual). so you could say the expected 'result' is that it is in the manual :) Actual result: -------------- The correct PHP Fatal error: Cannot use 'self' as class name as it is reserved in test.php on line 3 is provided, even though it isn't in the documentation. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 06:00:02 2025 UTC |
No, self (and parent) aren't keywords. You can declare a function self() {} without problems. They're just forbidden to use in class contexts for resolving any ambiguity about what self:: and parent:: should address. The class itself/parent of the class or the classes self/parent?