Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29106 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64456 invoked by uid 1010); 29 Apr 2007 23:30:41 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 64440 invoked from network); 29 Apr 2007 23:30:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Apr 2007 23:30:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=david.coallier@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=david.coallier@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.132.247 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: david.coallier@gmail.com X-Host-Fingerprint: 209.85.132.247 an-out-0708.google.com Received: from [209.85.132.247] ([209.85.132.247:17157] helo=an-out-0708.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/46-40858-D9A25364 for ; Sun, 29 Apr 2007 19:30:40 -0400 Received: by an-out-0708.google.com with SMTP id c28so1189726ana for ; Sun, 29 Apr 2007 16:30:34 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=WZRu72fEpj4QSBSIV7cMVtS+DFRXUr544EqMVWZmqjgL/h1Aruo5tIEJzD1FuMeCKT5d6/mF5ZT15bK7iZc2wKGJ8Gg0URu5RPDd3+kyCopB6gQX/lHYcUkiduK+J8fmwEVNi8NoiWX7cs5QF9+DgnYrTC9k7nan7hSmR+DMyDc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=QPl7lH7IT2IGh3NTqjNLafKSIfMOD+/Puk75yCEl5MPnlnu7e4qna1554+0k8GwBENHnoK3EL0lmnqgvd76yyMZpWWXlkgqYw38ZiwZgUFJfh/zu5nMXAyul8YWh9BqwqnaUxzMbrlQQKGzZv3JOPwRPg01cXyZ+UGAstYZunDQ= Received: by 10.100.238.9 with SMTP id l9mr3716641anh.1177889434198; Sun, 29 Apr 2007 16:30:34 -0700 (PDT) Received: by 10.100.226.11 with HTTP; Sun, 29 Apr 2007 16:30:34 -0700 (PDT) Message-ID: Date: Sun, 29 Apr 2007 19:30:34 -0400 Sender: david.coallier@gmail.com To: MaaSTaaR Cc: internals@lists.php.net In-Reply-To: <515493.75851.qm@web56303.mail.re3.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <515493.75851.qm@web56303.mail.re3.yahoo.com> X-Google-Sender-Auth: 1a69c799c945d3cc Subject: Re: [PHP-DEV] define and objects! From: davidc@php.net ("David Coallier") On 4/29/07, MaaSTaaR wrote: > Hello ... > > Firstly sorry for my bad English, my friend request from me to send this suggestion for PHP developer. > > The suggestion is support use constant as object, for example : > > class HelloWorld > { > function start() > { > echo 'Hello World'; > } > } > > define('OBJ',new HelloWorld); > > OBJ->start(); > > this will be good when we use object inside class, we will not need use global or $this, for example. > > With normal way : > > class MainClass > { > function One() > { > echo 'One'; > } > > function Two() > { > echo 'Two'; > } > } > > $Main = new MainClass; > > class AnotherClass > { > function P() > { > global $Main; // Note this line > > $Main->One(); > } > } > > With suggested way : > > class MainClass > { > function One() > { > echo 'One'; > } > > function Two() > { > echo 'Two'; > } > } > > define('MAIN',new MainClass); > > class AnotherClass > { > function P() > { > MAIN->One(); // use it directlly without global or $this > } > } > > > > --------------------------------- > Ahhh...imagining that irresistible "new car" smell? > Check outnew cars at Yahoo! Autos. You could just do class Main { public static function P() { echo 'woo'; } } class Yeah { public function S() { Main::P(); } } -- David Coallier, Founder & Software Architect, Agora Production (http://agoraproduction.com) 51.42.06.70.18