in Education by
What are the rules for naming a PHP variable?

1 Answer

0 votes
by

The following two rules are needed to be followed while naming a PHP variable:

  • A variable must start with a dollar symbol, followed by the variable name. For example: $price=100; where price is a variable name.
  • Variable names must begin with a letter or underscore.
  • A variable name can consist of letters, numbers, or underscores. But you cannot use characters like + , – , % , & etc.
  • A PHP variable name cannot contain spaces.
  • PHP variables are case-sensitive. So $NAME and $name both are treated as different variables.

Related questions

0 votes
    What are the disadvantages of PHP?...
asked Jul 13, 2021 in Education by JackTerrance
0 votes
    What is the purpose of @ in PHP?...
asked Jul 13, 2021 in Education by JackTerrance
0 votes
    What is the difference between “echo” and “print” in PHP?...
asked Jul 13, 2021 in Education by JackTerrance
0 votes
    Coming from a C# background the naming convention for variables and method names are usually either Camel Case or ... for Python? Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    I make a website on php and want to read some information from text file. the reason is if, i ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 8, 2022 in Education by JackTerrance
0 votes
    I make a website on php and want to read some information from text file. the reason is if, i ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    So this is a zany thing that I'm attempting to do, but what I am trying to achieve is querying ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    So this is a zany thing that I'm attempting to do, but what I am trying to achieve is querying ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    Okay, so let's say I have a webpage with a defined php $variable, and then I use include(" ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 11, 2022 in Education by JackTerrance
0 votes
    Okay, so let's say I have a webpage with a defined php $variable, and then I use include(" ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 11, 2022 in Education by JackTerrance
0 votes
    Okay, so let's say I have a webpage with a defined php $variable, and then I use include(" ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 11, 2022 in Education by JackTerrance
0 votes
    Which of these is a mechanism for naming and visibility control of a class and its content? (a) Object (b) ... & Packages of Java Select the correct answer from above options...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 13, 2022 in Education by JackTerrance
0 votes
    Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 13, 2022 in Education by JackTerrance
...