PHP Illegal Variables

PHP Variables Naming Previous Next PHP Variables Scope


You can not declare variable in following pattern given below.

  1. In PHP variables name not start with numeric value.
  2. In PHP variables name not separated by a hyphen.
  3. In PHP multi words variable not separated by whitespace.

Following are the illegal variable in php, if you create you get error.

Filename: php / illegal-variables.php


Code
<?php
echo $1numvar="Num Var";
echo $hyphen-var="Hyphen Var";
echo $whitespace var="Whitespace Var";
?>

Running Step.


Type Url - https://localhost/php/illegal-variables.php

Output

Parse error: syntax error, unexpected '2' (T_LNUMBER), expecting variable (T_VARIABLE) or '{' or '$' in C:wamp64wwwphp-error.php on line 2

Parse error: syntax error, unexpected 'var' (T_VAR) in C:wamp64wwwphp-error.php on line 3

Parse error: syntax error, unexpected 'var' (T_VAR), expecting ',' or ';' in C:wamp64wwwphp-error.php on line 4


Tags: PHP


Was this helpful ?

Related Code


Popular Code

Latest Code