name; } function naming($ID){ // IDの末尾が'ai'の場合大文字に変換。それ以外はIDに'-AI'を付与。 if(substr($ID, -2) == 'ai'){ $this->name = substr_replace($ID, 'AI', -2, 2); }else{ $this->name = $ID.'-AI'; } } } $X = new AI(); $X->naming(fgets(STDIN)); $X->hello();