This is a stupid question, but i want to know, how is named the OOP functionnality that consists to give a value to an object and dont lost the object, for example in javascript it works with the String object, but if i want to create an Object which i can set a value, how i do that ? :
// i set beer to budweiser
beer = new String('budweiser');
// beer is still String object and i changed its value ..
beer = 'Pabst';
But in PHP when i do something like :
//robert is a new guy instance, and he is cool
$robert = new Guy('cool');
//but you discover he is stealing ur money
$robert = 'asshole';
//now if i want to use a Guy method, i cant
$robert->throwRocks();
so i want to know, how this OOP functionality is named and how i can use it in PHP and JS ?
thanks !
Im not sure I understand your question (nor the humour), but you can make a class and assign variables to that class through the
construct&__setthen retrieve them through a method or property:Here is some pseudo code: