Solved

Defining Variable without $

Posted on 2006-10-22
3
134 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
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 350 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 100 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 50 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
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.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

773 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