これはばかげた質問ですが、知りたいのですが、オブジェクトに値を与え、オブジェクトを失わないようにするOOP機能の名前は、たとえばjavascriptではStringオブジェクトで機能しますが、作成したい場合は値を設定できるオブジェクト、それをどのように行うのですか?:
// i set beer to budweiser
beer = new String('budweiser');
// beer is still String object and i changed its value ..
beer = 'Pabst';
しかし、PHPでは次のようなことをします:
//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();
だから私は知りたいのですが、このOOP機能はどのように命名され、PHPとJSでどのように使用できますか?
ありがとう !