A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearMeaning of :: Operator in C# and PhP - page 1
User InfoPosts
Meaning of :: Operator in C# and PhP#1
In my work I have come across syntax like global:: (C#) or G:Loading($value) in Php, what do they mean?

posted date: 2008-12-30 07:47:00


Re: Meaning of :: Operator in C# and PhP#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-30 07:47:01


Re: Meaning of :: Operator in C# and PhP#3
In PHP :: is used to access static members or methods, see http://www.php.net/manual/en/language.oop5.static.php

posted date: 2008-12-30 07:51:00


Re: Meaning of :: Operator in C# and PhP#4
In C# :: is the namespace alias qualifier operator, and global indicates the global namespace. It is necessary if you have overlapping classes and namespaces.For example, if you have class Foo.Bar and Baz.Foo.Bar then the reference Foo.Bar may be an ambiguous reference as Foo.Bar exists in both the global namespace and the Baz namespace. However, by saying global::Foo.Bar you explicitly scope the reference to the global namespace and thus it is no longer ambiguous.More info here.

posted date: 2008-12-30 07:53:00


Re: Meaning of :: Operator in C# and PhP#5
If C#, :: is called the Namespace Alias Qualifier.It qualifies which namespace you are in exactly should there be ambiguities. For example:using MyNameSpace;...global::System.Datadifferentiates the System.Data namespace from MyNameSpace.System.Data.Have a look at C# reference on the :: operator:http://msdn.microsoft.com/en-us/library/htccxtad.aspxand more helpfully, the MSDN article demonstrating its usehttp://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx

posted date: 2008-12-30 07:54:00


Re: Meaning of :: Operator in C# and PhP#6
In C# the global:: operator is used to ensure that the following name is interpreted as a global name expression vs. a local one. The main use for this is when developers have a nested namespace where the name is the same as a global namespace. Without the global:: operator there is no way to access the global version. namespace Foo { namespace System { class DateTime {} class Example { object Example() { return System.DateTime.Now; // Returns Foo.System.DateTime.Now return global::System.DateTime.Now; // Returns mscorlib,System.DateTime.Now } } }}

posted date: 2008-12-30 07:55:00


Re: Meaning of :: Operator in C# and PhP#7
In PHP its called the Scope Resolution Operator (Paamayim Nekudotayim) and allows access to members or constants within a class

posted date: 2008-12-30 07:56:00


Re: Meaning of :: Operator in C# and PhP#8
In C#, the :: operator is the namespace alias qualifier. It is used to resolve identifiers to the appropriate namespace, especially in situations where ambiguities exist.So suppose that you create a namespace alias viausing IOAlias = System.IO;and wish to declare an instance of the StreamReader class. You could do this viaIOAlias::StreamReader sr = new StreamReader(path);Further, you can resolve to the global namespace viaglobal::System.IO.StreamReader sr = new StreamReader(path);

posted date: 2008-12-30 07:58:00


Re: Meaning of :: Operator in C# and PhP#9
Btw fun trivia about the hebrew name here: en.wikipedia.org/wiki/Paamayim_Nekudotayim

posted date: 2008-12-30 08:04:00


Re: Meaning of :: Operator in C# and PhP#10
in Class based object oriented programming languages (like C++, Java, PHP, ...) there are properties (also called fields) which are the data and are simply variables or constants, and methods which are the functionality of the class and are actually functions (routins).each class can be instanciated as objects. each object has all data and functionality of the base class at the beginning, but the data can be changed and be different from one object, to another.there are 2 kinds of properties and 2 kinds of methods.some properties are shared between all objects of a class. this means that if you change this data of the class, the same data of all the instanciated objects will be changed to the neew value. this kind of properties are called Class properties, or Static properties (because when you are defining these variables, in most languages you will use the static keyword).some other properties are specific for each object. changing the data of on object, does not affect the data of other objects. these are called object properties or instance properties.some methods are called from an object, there are called object methods. these are object methods and to use them, you need to first instanciate a class and use the object. some other methods are called by using the class itself. these are class methods (or static methods) if you want one of these functions, there is no need for an object.to use object properties/methods, in PHP (like C++) you should use the -> operator:object->method();object->property;to use class properties/methods in PHP (like C++) you should use the :: operator:class::method();class::property;in languages like Jave, the operator . is used for all of properties/methods:object.method();class.property;suppose you have a Circle class. this class defines some data like radius, and center cordinates, and a constant for PI value. also has a method to calculate the area of the circle.here is some PHP code to make it clear:<?phpclass Circle { public $radius; public $centerX; public $centerY; public static $PI = 3.1415; public function __construct($r,$x,$y) { $this->radius = $r; $this->centerX = $x; $this->centerY = $y; } public function getArea() { return self::$PI * $this->radius * $this->radius; }}$circle1 = new Circle(10,0,0);echo $circle1->getArea() . "<br>\n";$circle2 = new Circle(15,10,12);echo $circle2->getArea() . "<br>\n";Circle::$PI = 3.14;echo $circle1->getArea() . "<br>\n";echo $circle2->getArea() . "<br>\n";?>in this example we define a circle class which has object properties (radius, centerX, CenterY), object methods (getArea()), and a Class property (PI).by changing the PI static property, the area of both objects will be affected.

posted date: 2008-12-30 12:07:00


Re: Meaning of :: Operator in C# and PhP#11
Consider the following example:namespace A { public class MyClass { }} namespace namespaceB{ public class A { public class MyClass { } } public class OtherClass { public A.MyClass MyAClass; }}Explanation:In the example above, the compiler would always resolve the MyAClass to the type namespaceB.A.MyClass. If you wanted it to be A.MyClass, there was no way to do it until C# 2.0. In C# 2.0, you would use: public class MyOtherClass{ public global::A.MyClass yAClass; }To indicate that you shouldn(t use the local namespace scope, but rather, the root namespace.

posted date: 2010-09-15 04:50:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.