
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

4K+ Views
Introduction$_SERVER is a superglobal that holds information regarding HTTP headers, path and script location etc. All the server and execution environment related information is available in this associative array. Most of the entries in this array are populated by web server.PHP versions prior to 5.4.0 contained $HTTP_SERVER_VARS contained same information but has now been removed. Following are some prominent members of this arrayPHP_SELF − stores filename of currently executing script. For example, a script in test folder of document root of a local server returns its path as follows −ExampleThis results in following output in browser with http://localhost/test/testscript.php URL/test/testscript.phpSERVER_ADDR − This ... Read More

3K+ Views
IntroductionIn PHP, it is possible to have a user-defined compund data type using class keyword. A new instance of class is an object. Charactersitics of object are as per definition of class, which may contain property, constant and method members.Accessibility (also called visibility) of a class member depends on visibility prefix keyword attached in its definition. PHP has three visibility keywords - public, private and protected. A class member declared with public keyword is accessible from anywhare. A protected member is accessible from within its class and by inheriting class. On the other hand, a private member can only be ... Read More

287 Views
IntroductionThis feature of late static binding in PHP is used to refercalled class in static inheritance. When static methods are called, name of class is attached with scope resolution operator (::) while in case of other instance methods we call them using name of object. The static:: will not be resolved using the class in which method is defined ,instead will be computed using runtime information. Static references to the current class are resolved using the class in which the function belongs, not where it was definedExampleIn following code, parent class calls static ethod with self:: prefix. Same method when ... Read More

1K+ Views
IntroductionA string representation of any object in the form of byte-stream is obtained by serialze() function in PHP. All property variables of object are contained in the string and methods are not saved. This string can be stored in any file.To retrieve the object from the byte stream, there is unserialize() function. Definition of corresponding class must be available before calling unserialize()function.ExampleFirst let us serialize an object of following class and store the string in a file.In current folder, obj.txt is created. To unserialize, following code reconstructs object from the byte stream read from the given fileExampleRead More

7K+ Views
IntroductionIn PHP, the double colon :: is defined as Scope Resolution Operator. It used when when we want to access constants, properties and methods defined at class level. When referring to these items outside class definition, name of class is used along with scope resolution operator. This operator is also called Paamayim Nekudotayim, which in Hebrew means double colon.SyntaxInside classTo access class level items inside any method, keyword - self is usedIn child classIf a parent class method overridden by a child class and you need to call the corresponding parent method, it must be prefixed with parent keyword and scope resolution ... Read More

9K+ Views
IntroductionData members declared inside class are called properties. Property is sometimes referred to as attribute or field. In PHP, a property is qualified by one of the access specifier keywords, public, private or protected. Name of property could be any valid label in PHP. Value of property can be different for each instance of class. That's why it is sometimes referred as instance variable.Inside any instance method, property can be accessed by calling object's context available as a pesudo-variable $this. If a property is declared as public, it is available to object with the help of -> operator. If a ... Read More

4K+ Views
IntroductionIn PHP, objects are passed by references by default. Here, reference is an alias, which allows two different variables to write to the same value. An object variable doesn't contain the object itself as value. It only contains an object identifier which allows using which the actual object is found. When an object is sent by argument, returned or assigned, the different variables are not aliases − instead, they hold a copy of the identifier, pointing to the same object.ExamplePHP has spl_object_hash() function that returns unique hash ID of an object. In following code, two object variables, referring to same ... Read More

3K+ Views
IntroductionPHP has a comparison operator == using which a simple comarison of two objecs variables can be performed. It returns true if both belong to same class and values of corresponding properties are are same.PHP's === operator compares two object variables and returns true if and only if they refer to same instance of same classWe use following two classes for comparison of objects with these opratorsExampletwo objects of same classExample$a=new test1(10, 20); $b=new test1(10, 20); echo "two objects of same class"; echo "using == operator : "; var_dump($a==$b); echo "using === operator : "; var_dump($a===$b);Outputtwo objects of same class using == operator ... Read More

9K+ Views
IntroductionMagic methods in PHP are special methods that are aimed to perform certain tasks. These methods are named with double underscore (__) as prefix. All these function names are reserved and can't be used for any purpose other than associated magical functionality. Magical method in a class must be declared public. These methods act as interceptors that are automatically called when certain conditions are met.Following magical methods are currently available in PHP__sleeppublic __sleep ( void ) : arrayserialize() method in class checks if it has a function name __sleep(). If so, that function is executed prior to any serialization. It ... Read More

694 Views
IntroductionInterface is an important feature of object oriented programming by which it is possible to specify methods to be implemented by a class, without having to define how they should be implemented.PHP supports interface by way if interface keyword. Interface is similar to class but with methods without definition body. Methods in interface must be public. An inherited class that implements these methods must be defined with implements keyword instead of extends keyword, and must provide implementations of all methods in parent interface.SyntaxAll methods from interface must be defined by the implementing class, otherwise PHP parser throws exceptionExample Live DemoOutputThe error ... Read More