• Home
  • About
    • PI photo

      PI

      Beginner's Blog

    • Learn More
    • Github
  • Posts
    • All Posts
    • All Tags
    • All Categories
  • Projects

[PHP] ->와 => 연산자

📆 Created: 2024.11.03 Sun

🗓️ Updated: 2024.11.08 Fri

Reading time ~1 minute

-> 와 => 연산자

-> 연산자

Object 연산자 ->: Object 범위에서 객체의 메서드 및 속성에 엑세스할 때 사용
A -> B일 때, A 객체의 구성원인 B에 접근한다

class test {
    public $name = "";

    function set_name($name) {
        $this->name = $name;
        return $this;
    }

    function get_name() {
        echo $this->name;
    }
}


$obj = new test();
$obj -> name = "Hong Gildong";
$obj -> get_name();

=> 연산자

=>: 배열의 키, 값을 할당할 때 사용한다

$arr = array(
    "A" => 1,
    "B" => 2,
    "C" => 3,
    "D" => 4
    );

참고

  1. -> 연산자 의미
  2. -> 와 =>의 차이점
  3. PHP Manual


WEBPHP Share Tweet +1
/#disqus_thread