|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-10-18 17:44 UTC] webmaster at adriaportal dot com
Description:
------------
Error by using method with name use();
!!!! No error with method name changed to _use() !!!!
Reproduce code:
---------------
<?php
class Block {
private $block = "";
private $value = "";
private $name = "";
private $out = "";
function __construct($blockName) {
$this->name = $blockName;
}
public function use() {
$this->value = $this->block;
$this->out = "";
}
}
?>
Expected result:
----------------
No error.
The word USE is very USED by programming. Here is used in a class block of code as name of method, bud here is a conflict with may by documented keyword use in PHP. The namespace use this keyword.
Actual result:
--------------
Parse error: syntax error, unexpected T_USE, expecting T_STRING in C:\webs\test\bug.php on line 15
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 11:00:01 2025 UTC |
I'm cannot english language so good, only pasiv, but why is conflict when word 'use' in this fall is called as part of a structure, a closed block, and the syntax is here $instance->method() and this is different as method() or method. This is a bad isolation of programm blocks. In Java can you write: public class Use { public static void main(String[] args) { Use use = new Use(); use.use(); } public Use() { } public void use() { } } And this class work without any problem. And cherio, i'm must work to.I'm cannot english language so good, only pasiv, but why is conflict when word 'use' in this fall is called as part of a structure, a closed block, and the syntax is here $instance->method() and this is different as method() or method. This is a bad isolation of programm blocks. In Java can you write: public class Use { public static void main(String[] args) { Use use = new Use(); use.use(); } public Use() { } public void use() { } } And this class work without any problem. And cherio, i'm must work to.