Jump to content

pls clear my confusion


Gomesh

Recommended Posts

It resolves scope =P

 

Yeah the double colon (::) operator is used when you want to access static properties, constants, and overridden methods

 

http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php check out the manual

 

A quick example. Say we had a class, foo, and a class footoo that is derived from foo. If foo has a method, bar(), footoo can access that method, even if it overrode it, using the scope resolution operator

 

class foo {
function bar() {
"I am Foo";
}
}//end class

class footoo extends foo {
function bar() {
parent::foo();//note the use of ::
echo "And I am footoo";
}
}

 

There is more too it though, so check out the manual for the other uses, and examples

 

Edit; Marcus beat me, but i feel this is worth posting

class foo {
  function bar() {
    echo "I am Foo";
  }
}//end class

class footoo extends foo {
  function bar() {
    parent::foo();//note the use of ::
    echo "And I am footoo";
  }
}

 

Nevermind you were missing an echo statement

why we use global in any function for example:-

 

 

function get_director() {

  global $movie_director;

  global $director;

  $query_d = "SELECT people_fullname " .

            "FROM people " .

            "WHERE people_id='$movie_director'";

  $results_d = mysql_query($query_d)

    or die(mysql_error());

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.