php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #11142 '::' for object variables. Static code
Submitted: 2001-05-27 14:39 UTC Modified: 2002-01-28 20:49 UTC
From: foobardotcom at poczta dot onet dot pl Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.5 OS: all
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: foobardotcom at poczta dot onet dot pl
New email:
PHP Version: OS:

 

 [2001-05-27 14:39 UTC] foobardotcom at poczta dot onet dot pl
I just want, you make this code possible:

<?php
  class foo {
    var $bar = "dot";
  }
  echo foo::bar;
?>

============================================================

Second request is about static code part in class declaration. It is because 'var' statement doesn't support function results. There is way for omit this problem -- do it using constructor.
There is one problem. If I want to use it by '::' operator, I must use constructor before using this class... and there are so many problems with it.

My proposition is that:

<?php
  class foo {
    static {
      $conn = pg_connect("dbname=example");
    }
    function getConnection() {
      return $this->conn;
    }
  }
  $globalConn = foo::getConnection();
  // ...
?>

Meaning of that is just request for operations on classes, not on instances only.
Static part of class declaration is very usefull. In that code you can e.g. place other constructions -- for() or while().

I believe in you!

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-28 20:49 UTC] yohgaki@php.net
Will be in ZE2
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 10:01:31 2024 UTC