PHP is a loosely typed programming language. It means that you don’t have to declare a variable before using it. When you assign value to a variable, its data type is automatically assigned to the variable. When you reassign a value having a different data type to pre-existing variable the data type also changes without a fuss. PHP has least syntactical rules to be followed by programmers so it makes programming in PHP a lot easier. On violation of these rules you will get a parse error reported in the browser. Tokens in PHP are all elements of a program.
If you know HTML then it doesn’t mean that you know PHP. PHP is a scripting language whereas HTML is a mark-up language. HTML has a set of tags to create WebPages that is rendered by browser to display the text. PHP gives you the capability to add interaction to the static pages created with HTML.
Tokens in PHP
In any programming language a token is defined as an independent element used in creating the program. In PHP a token is considered an individual component of a program. The keywords, variables, constants, operators and strings used in a program are tokens in PHP.
Keywords– These are the reserved words that are already defined in PHP. You cannot use them to declare variables or constants.
Variables– Variables in PHP are declared by the programmer to store the values to be used in a program for processing. Variables begin with a $. All variables declarations follow the rules that are applicable in any programming language you already comfortable with.
Constants– these are the fixed Numeric, Text or Boolean values that a programmer want to use more than once. A constant is a value identified by a name and it is restricted to be updated.
Operators– operators are used to process data to convert it into information. Addition, subtraction, division, comparisons, increment are some of the common operations and are done by using operators with variables and constants.
Strings– collection of character are called strings.