Phpdynamic

PHP and MySQL Programming Guides, Tutorials, & Articles

Posts Tagged Fundamentals

PHP Operators

MAR 25

Operators and Operands

Up to this point we have been working with only a handful of operators such as the assignment operator and some basic arithmetic operators. PHP offers many other kinds of operators, we’ll cover and explain them in this tutorial.

An operator is a symbol that is used to perform a particular action on a operand, which is the input data used in the operation. For example, in the following expression: 2 + 3, the (+) symbol represents an operator and the numerical values 2 and 3 represent operands. PHP supports three types of operators, unary, binary, and ternary which operate on single operands, two operands, and three operands, respectively.

To hit the ground running, below is a table containing a complete listing of all operators available in PHP, with the highest-precedence operators at the top along with their associativity.

Operators Associativity
() N/A
new N/A
[] Right
! ~ ++ — (int) (double) (string) (array) (object) @ Right
/ * % Left
+ – . Left
< < >> left
< <= > >= N/A
== != === !== N/A
& Left
^ Left
| Left
&& Left
|| Left
? : Left
= += -= *= /= .= %= &= |= ^= ~= < <= >>= Left
Print Right
AND Left
XOR Left
OR Left
, Left

Read more…

What are Constants?

MAR 25

PHP Constants

A constant represents a literal value that will remain the same, for example the value for PI (3.14), the number of days in a week (7), or the number of ounces in a pound (16) all represent numbers that will never change. A constant can store a value similar to a variable, but that value cannot be modified during the execution of a script, once that constant is initialized. Constants are created using the built-in define() function, by assigning an identifier name to the constant along with a literal value.

Read more…

Beginning PHP – Language Syntax

MAR 11

Syntax and Semantics

All programming languages must follow a proper syntax, which is a set of rules that control the arrangement of words, numbers, and symbols for writing valid code; and PHP is no exception. In the same sense that English sentences have to follow certain grammatical rules to have a proper meaning (semantic), all PHP statements must follow a certain set of syntax rules to execute correctly.

Read more…

Beginning PHP – The Fundamentals

MAR 10

The Whole Picture

You have an operational web server with PHP installed and configured, and you might be wondering how all the pieces fall together and perform anything useful. Before we move along any further, we would like to share the underlying concept on how PHP and Apache work together; as this will provide you with a solid foundation to understanding the examples used throughout the tutorial.

Read more…