?
Solved

Defining Variable without $

Posted on 2006-10-22
3
Medium Priority
?
139 Views
Last Modified: 2006-11-18
Hello,

I want to set a variable in PHP without using $

Like this:

echo "Content" . _Footer;


How can I do this?

         _Footer = "Foobar"

Thanks!
0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1400 total points
ID: 17784912
>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
 
LVL 14

Assisted Solution

by:Aamir Saeed
Aamir Saeed earned 400 total points
ID: 17784993
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
 
LVL 48

Assisted Solution

by:hernst42
hernst42 earned 200 total points
ID: 17787318
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question