|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-01-28 20:49 UTC] yohgaki@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 08:00:01 2025 UTC |
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!