php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49512 Not follow the Ooop's law
Submitted: 2009-09-09 12:44 UTC Modified: 2009-09-09 12:57 UTC
From: binay dot kumar at osvin dot biz Assigned:
Status: Not a bug Package: *Programming Data Structures
PHP Version: 5.2.10 OS: Any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
5 + 47 = ?
Subscribe to this entry?

 
 [2009-09-09 12:44 UTC] binay dot kumar at osvin dot biz
Description:
------------
<?php 
class xyz
{
	
	public function getName($id)
	{
		return $id;
	}
}
xyz::getName(1);
?>

## in the above class i can access the class xyz method by "::", however i have not created the instance of the class.

by the oop's law , we can access a method by this way,method defined as static method. its working fine in both case either create a object of the class or by "::" to access.
can please describe me the things because its not following the oop's law.


Regards
Binay Kumar



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-09 12:57 UTC] sjoerd@php.net
Thank you for your bug report.

You should indeed use the static keyword if you want to call a method without creating an object instance. However, PHP allows it and generates an E_STRICT warning. This is meant to work like this, therefore this is not a bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 14:01:29 2024 UTC