Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Defining Variable without $

Posted on 2006-10-22
3
Medium Priority
?
141 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

609 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