Defining Variable without $

Hello,

I want to set a variable in PHP without using $

Like this:

echo "Content" . _Footer;


How can I do this?

         _Footer = "Foobar"

Thanks!
LVL 16
hankknightAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
>I want to set a variable in PHP without using $
you cannot. php variables use $.

you can however define constants:
http://php.net/define

define("_Footer", "Foobar");

echo "Content" . _Footer;
0
 
Aamir SaeedConnect With a Mentor Commented:
Unlike with most other languages (a notable exception being Perl), PHP uses a special character to define a word as a variable. Variables in PHP are prefixed by a dollar sign ('$').

Variables do not require formal declaration. They will automatically be declared when a value is assigned to it. In the example below, the variable myvar, is assigned a string value:
$myvar = "Some string";

Variables are "loosely typed". This means that their type does not have to be fixed. The examples below are both valid. PHP determines the variable type in either case:
$myvar = "1";
$myvar = 1;
0
 
hernst42Connect With a Mentor Commented:
Other Option would be to recompile php and modify the php parser so the _ is the token for variables. Then the _ may not be used inside names.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.