<?php class Name { private $name; function __construct($name) { $this->name = $name; } function length() { return mb_strlen($this->name, 'UTF-8'); } /* object replace() */ function ooReplace($needle, $replace) { $this->name = str_replace($needle, $replace, $this->name); return $this->name; } /* functional replace() */ function replace($needle, $replace) { return str_replace($needle, $replace, $this->name); } function __toString() { return $this->name; } } $name = new Name("žluťásek"); var_dump((string) $name); // string(11) "žluťásek" var_dump($name->length()); // int(8) var_dump($name->replace('ťáse', 'ční')); // string(10) "žlučník" var_dump((string) $name); // string(11) "žluťásek"
good stuff, good stuff.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
good stuff, good stuff.