php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14178 PHP global function and class method names conflict
Submitted: 2001-11-22 10:36 UTC Modified: 2001-11-22 10:41 UTC
From: jmmolina at ifrance dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.0.6 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jmmolina at ifrance dot com
New email:
PHP Version: OS:

 

 [2001-11-22 10:36 UTC] jmmolina at ifrance dot com
It seems that class methods are not really part of the class. The scope of
a method definition is global not local to the class. I have tried the
following: 

class CMyClass 
{ 
function Print () 
{ 
} 
} 

It doesn't work because the PHP parser thinks that the "Print"
method is the "print" PHP global function. I have tried to force
scope: 

class CMyClass 
{ 
function CMyClass::Print () 
{ 
} 
} 

But it doesn't work. The only solution I found is to use an other name for
my method, even if it really prints something.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-22 10:41 UTC] derick@php.net
print is a reserved word in PHP (not a real function), you can not use this as a function name.
Not a bug -> bogus
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 02:01:30 2024 UTC