PHP Class Attribute With Example

An attribute is known as data members and is used to hold data of a class. The data that it holds are specific to the nature of the class in which it has been defined. For example, a Book class would hold data related to a book, an Publisher class would hold data related a … Continue reading PHP Class Attribute With Example

Advertisements

Object Oriented Programming in PHP

Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which may contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods.It organizes the data and structure of an application. Here in this tutorial, you will learn about basic OOP … Continue reading Object Oriented Programming in PHP

PHP Operator precedence

The precedence of an operator specifies how "tightly" it binds two expressions together. In general, operators have a set precedence, or order, in which they are evaluated. Certain operators have higher precedence than others; for example, the multiplication operator has higher precedence than the addition operator. For example, in the expression 8 + 5 * 2, … Continue reading PHP Operator precedence

PHP Magic constants

PHP provides a large number of predefined constants to any script which it runs. Magic constants have a funny syntax, placing two underscores before and after the constant's word representation. There are nine magical constants that change depending on where they are used. For example, the value of __LINE__ depends on the line that it's … Continue reading PHP Magic constants

PHP superglobal variables

The complete list of superglobals variables: 1. $GLOBALS—An array of all global variables (Like the global keyword, this allows you to access global variables inside a function—for example, as $GLOBALS[‘myvariable’].) 2. $_SERVER—An array of server environment variables 3. $_GET—An array of variables passed to the script via the GET method 4. $_POST—An array of variables … Continue reading PHP superglobal variables

Understanding Variable Scope

The term scope refers to the places within a script where a particular variable is visible. The six basic scope rules in PHP are as follows: 1. Built-in superglobal variables are visible everywhere within a script. 2. Constants, once declared, are always visible globally; that is, they can be used inside and outside functions. 3. … Continue reading Understanding Variable Scope

Type Casting in PHP

You can pretend that a variable or value is of a different type by using a type cast.This feature works identically to the way it works in C.You simply put the temporary type in parentheses in front of the variable you want to cast. For example, $total= 0; $totalamount=0.00; $totalamount = (float)$total;

PHP’s Data Types

PHP supports the following basic data types: 1. Integer—Used for whole numbers 2. Float (also called double)—Used for real numbers 3. String—Used for strings of characters 4. Boolean—Used for true or false values 5. Array—Used to store multiple data items 6. Object—Used for storing instances of classes Two special types are also available: NULL and … Continue reading PHP’s Data Types