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

Link to comment
Share on other sites

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());

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.