note 75897 deleted from language.oop5.visibility by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: chris at chrisstockton dot org 

----

One note that I have not found in the documentation but have found to be valid is a alternative syntax for visibility assignment. Take into consideration a previous example of:

<?php

class Foo
{

    const sudo = 'sudo';
    const finger = 'finger';
    const strings = 'strings;

    private $a;
    private $b;
    private $c;
    private $d;
    private $e;
    private $f;

    protected $g;
    protected $h;
    protected $i;
    protected $j;

    public $k;
    public $l;
    public $m;

    public function __construct() {}

}

?>

Can also be written, slightly more elegantly as:

<?php

class Foo
{

    const
        sudo = 'sudo',
        finger = 'finger',
        const strings = 'strings;

    private
        $a,
        $b,
        $c,
        $d,
        $e,
        $f;

    protected
        $g,
        $h,
        $i,
        $j;

    public
        $k,
        $l,
        $m;

    public function __construct() {}

}

?>

Just make sure to end the assignment with your semicolon, and separate assignment with commas.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.