본문 바로가기
백엔드

[php] What does this mean in PHP: -> or =>

by 작은소행성 2022. 7. 8.

누군가에겐 이런걸 왜 몰라? 할 수 있지만 

나는 문법 하나하나 사용되는 뜻을 알고 사용하고 싶어서 찾아보았다. 

 

 

-> 

 (Object Operator)

인스턴스에서 메서드를 호출하거나 

객체 범위 내에서 객체에 접근하기 위해서 사용한다. 

class a{
   public function getData(){
      $variable = 'What does this mean in PHP: -> or =>';
      return $variable;
   }
}

$bar = new a;
$bar->getData();

 

 

 

=>

 (Double Arrow Operator)

배열의 키, 값을 할당할 때 사용한다. 

 

$Result = array(
  'result1' => '결과1',
  'result2' => '결과2',
  'result3' => '결과3'
);

 

 

 

 

https://stackoverflow.com/questions/3037526/where-do-we-use-the-object-operator-in-php

https://stackoverflow.com/questions/14037290/what-does-this-mean-in-php-or

반응형