🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.php
Article #231508

Re: Pewnie głupie pytanie, ale się uczę ;)

#231508
From: 0x77
Date: Sat, 14 Jan 2017 22:30
26 lines
1601 bytes
> Ale niech mi ktoś prosto wyjaśni jak np. podejść do:
> $obiekt->funkcja1($arg)->funkcja2() ?

To się nazywa chaining.
Najprościej tłumacząc, poprzedzające funkcje muszą zwracać obiekt $this.

class z
{
   function x() {
     echo '1';
     return $this;
   }

   function y() {
     echo '2'
     return $this;
   }
}

$v = new z;
$v->x()->y();


-- 
Pzdr.,
0x77
Technical Details
Message-ID: <587aa694$0$15197$65785112@news.neostrada.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!peer03.am4!peer.am4.highwinds-media.com!peer01.fr7!futter-mich.highwinds-media.com!news.highwinds-media.com!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!unt-spo-a-02.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
References: <878tqd1gzl.fsf@chata.almaop.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!peer03.am4!peer.am4.highwinds-media.com!peer01.fr7!futter-mich.highwinds-media.com!news.highwinds-media.com!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!unt-spo-a-02.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
Subject: Re: Pewnie głupie pytanie, ale
 się uczę ;)
References: <878tqd1gzl.fsf@chata.almaop.pl>
From: 0x77 <0x77@wp.pl>
Newsgroups: pl.comp.lang.php
Date: Sat, 14 Jan 2017 23:30:47 +0100
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0
MIME-Version: 1.0
In-Reply-To: <878tqd1gzl.fsf@chata.almaop.pl>
X-Antivirus: avast! (VPS 170114-0, 2017-01-14), Outbound message
X-Antivirus-Status: Clean
Lines: 27
Message-ID: <587aa694$0$15197$65785112@news.neostrada.pl>
Organization: Telekomunikacja Polska
NNTP-Posting-Host: 5.172.234.201
X-Trace: 1484433044 unt-rea-a-02.news.neostrada.pl 15197 5.172.234.201:2564
X-Complaints-To: abuse@news.neostrada.pl
X-Received-Bytes: 1378
X-Received-Body-CRC: 2039955403
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit