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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: binay dot kumar at osvin dot biz
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sun Oct 27 16:01:27 2024 UTC