[ create a new paste ] login | about

Link: http://codepad.org/zlQEMPqK    [ raw code | output | fork | 2 comments ]

PHP, pasted on Sep 22:
<?php

class ChainMe {

    public function hello() {
        echo 'Hello ';

        return $this;
    }

    public function good($is = false) {
        if ($is === true) {
            echo 'beautiful ';
        }

        return $this;
    }

    public function day() {
        echo "world!\n\n";

        return $this;
    }

}

$happy = new ChainMe();
$happy
    ->hello()
    ->good(true)
    ->day();

$meh = new ChainMe();
$meh->hello()->good()->day();

?>


Output:
1
2
3
4
Hello beautiful world!

Hello world!



Create a new paste based on this one


Comments:
posted by sandytest@gmail.com on Dec 7
gfgvfg
reply
posted by sandytest@gmail.com on Dec 7
gffawsdghjgswahdgewagdetgadhsfcxgdsdcsbvcxgsfvxs
reply