Delimiters in php

Perl-style regular expressions emulate the Perl syntax for patterns, which means that each pattern must be enclosed in a pair of delimiters. Traditionally, the slash (/) character is used; for example, /pattern/. However, any nonalphanumeric character other than the backslash character () can be used to delimit a Perl-style pattern. This is useful when matching … Read more

implode function in php

The implode() function does the exact opposite of explode()—it creates a large string from an array of smaller strings $string = implode(separator, array); The first argument, separator, is the string to put between the elements of the second argument, array. To reconstruct the simple comma-separated value string, simply say $fields = array(‘Fred’, ’25’, ‘Wilma’);$string = … Read more

substr in php

If you know where the data that you are interested in lies in a larger string, you can copy it out with the substr() function: $piece = substr(string, start [, length ]); The start argument is the position in string at which to begin copying, with 0 meaning the start of the string. The length … Read more

php echo

To put a string into the HTML of a PHP-generated page, use echo. While it looks— and for the most part behaves—like a function, echo is a language construct. This means that you can omit the parentheses, so the following are equivalent: echo “Printy”;echo(“Printy”); // also valid You can specify multiple items to print by … Read more

php function

A function is a named block of code that performs a specific task, possibly acting upon a set of values given to it, or parameters, and possibly returning a single value. Functions save on compile time—no matter how many times you call them, functions are compiled only once for the page. They also improve reliability … Read more

Casting Operators in php

Although PHP is a weakly typed language, there are occasions when it’s useful to consider a value as a specific type. The casting operators, (int), (float), (string), (bool), (array), (object), and (unset), allow you to force a value into a particular type Table of PHP casting operators Operator Synonymous operators Changes type to (int) (integer) … Read more

Logical Operators in php

Logical operators in php provide ways for you to build complex logical expressions. Logical operators treat their operands as Boolean values and return a Boolean value. There are both punctuation and English versions of the operators (|| and or are the same operator). The logical operators are Logical AND (&&, and) The result of the … Read more

Bitwise Operators in php

The bitwise operators act on the binary representation of their operands. Each operand is first turned into a binary representation of the value, as described in the bitwise negation operator entry in the following list. All the bitwise operators work on numbers as well as strings, but they vary in their treatment of string operands … Read more

String Concatenation Operator in php

Manipulating strings is such a core part of PHP applications that PHP has a separate string concatenation operator (.). The concatenation operator appends the righthand operand to the lefthand operand and returns the resulting string. Operands are first converted to strings, if necessary. For example: $n = 5;$s = ‘There were ‘ . $n . … Read more

Arithmetic Operators in php

The arithmetic operators are operators you’ll recognize from everyday use. Most of the arithmetic operators are binary; however, the arithmetic negation and arithmetic assertion operators are unary The arithmetic operators are: Addition (+) The result of the addition operator is the sum of the two operands Subtraction (−) The result of the subtraction operator is … Read more