Quickupdate

  • Home
  • Top Trending
    • Top Android Apps
    • Top Ios Apps
  • Featured
  • About Us
  • Contact us
  • Privacy Policy and Disclaimer

Friday, 10 January 2020

Oops PHP : Access Modifires

 Developers     January 10, 2020     No comments   

There are 3 types of access modifiers.
public : public property or method can be accessed Form anywhere (This is by default)
protected : protected proerty can be accessed With in the class & child class which extending parent class
private : "private" property or method can be access ONLY in the class.


NOTE: if you want to Access a "Private Property" Which is only accessible inside the class, then for that,
first, you have to create a "Public function", Then access that "Public function" after creating an object.


<?php

class AccessModifiers
{

    public $name;
    protected $color;
    private $height;

    function get_protected($color)
    {
        return $this->color = $color;
    }
}

$a_Obj = new AccessModifiers();
echo $a_Obj->name = 'mango. <br>';

echo $a_Obj->get_protected("red");

?>

  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

0 comments:

Post a Comment

Popular Posts

  • How to upload the existing folder on GitHub Or GitLab?
    These are the steps to upload the existing folder on GitHub Or GitLab. Whenever you want to push your existing folder to git or GitHub you m...

Categories

  • FAANG (2)
  • Javascript (6)
  • Node (1)
  • Project Management (1)
  • React (9)
  • SQL (1)
  • Testing (1)

Blog Archive

  • January 2023 (1)
  • January 2022 (1)
  • November 2021 (3)
  • October 2021 (3)
  • August 2021 (1)
  • July 2021 (7)
  • June 2021 (12)
  • February 2021 (1)
  • January 2021 (1)
  • January 2020 (3)
  • August 2019 (3)