
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 1060 Articles for PHP

242 Views
IntroductionMany syntax constructs in PHP are implemented via referencing mechanisms. If reference to a global variable is unset in a function, the same variable in global namespace is not removed.Example Live DemoOutputGlobal $va1 is intact.Hello World, Hello World Hello PHP, Hello PHP Hello PHPdebug_zval_dump() function can be used if a variable has references to other variables

1K+ Views
IntroductionIn PHP, a function can also be made to return a reference. This is useful to find to which variable a reference should be bound. To define a function which returns reference, prefix its name by & sign.ExampleIn following example, myfunction() is defined to return by reference. It contains a static variable whose reference is returned and assigned to a global variable. Value of local static variable will also change its reference ouside is assigned with different value.Example Live DemoOutputThis example gives following outputx Inside function: 10 returned by reference: 10 x Inside function: 20method returning referenceA class can also ... Read More

12K+ Views
IntroductionIn PHP, arguments to a function can be passed by value or passed by reference. By default, values of actual arguments are passed by value to formal arguments which become local variables inside the function. Hence, modification to these variables doesn't change value of actual argument variable.When arguments are passed by reference, change in value of formal argument is reflected in actual argument variable because the former is a reference to latter. Thus pass by reference mechanism helps in indirectly manipulating data in global space. It also helps in overcoming the fact that a function can return only one variable.Pass ... Read More

5K+ Views
IntroductionIn PHP, References enable accessing the same variable content by different names. They are not like pointers in C/C++ as it is not possible to perform arithmetic oprations using them. In C/C++, they are actual memory addresses. In PHP in contrast, they are symbol table aliases. In PHP, variable name and variable content are different, so the same content can have different names. A reference variable is created by prefixing & sign to original variable. Hence $b=&$a will mean that $b is a referewnce variable of $a.Assign By ReferenceIn following example, two variables refer to same valueExample Live DemoOutputChange in value ... Read More

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

284 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