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
 [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-2021 The PHP Group
All rights reserved.
Last updated: Wed Oct 20 14:03:39 2021 UTC