Class Setter Method

Setters are methods used to give the values of a property. Setters may apply some filtering and validation before accepting the value.

Setters are usually created with a getter method.

<?php

    class x {
        private $property;

        public function setProperty($value) {
            $this->property = $value;
        }
    }

?>

Documentation

See also What are getters and setters methods in PHP? and The Magic of PHP Getters, Setters, and Readonly Classes: Crafting Clean and Efficient Code.

Related : Class, Class Getter Method, Class Wither Method, Encapsulation

Added in PHP 5.0+