# dollars and sense.

- Thread: https://externals.io/message/7340
- Original archive: https://news-web.php.net/php.internals/7340
- Started by Michael Hawley on 2004-01-27T02:34:45+00:00
- Messages: 8
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #7340 — Michael Hawley — 2004-01-27T02:34:45+00:00

URL: https://externals.io/message/7340#7340

Why must variable names begin with $?  I can't see any
real reason, except when signalling a replacement within
a string (e.g., "... $var ...").  The language would be less
cumbersome if the dollar was optional otherwise.

Mike

---

## #7341 — Andrei Zmievski — 2004-01-27T02:46:34+00:00

URL: https://externals.io/message/7340#7341 · In reply to: #7340

> Why must variable names begin with $?  I can't see any
> real reason, except when signalling a replacement within
> a string (e.g., "... $var ...").  The language would be less
> cumbersome if the dollar was optional otherwise.

You are about 9 years late to the party.

-Andrei

"Claiming Java is easier than C++ is like
 saying that K2 is shorter than Everest." 
 -- Larry O'Brien (editor, Software Development)

---

## #7342 — Ken Tossell — 2004-01-27T03:31:28+00:00

URL: https://externals.io/message/7340#7342 · In reply to: #7340

> Why must variable names begin with $?  I can't see any
> real reason, except when signalling a replacement within
> a string (e.g., "... $var ...").  The language would be less
> cumbersome if the dollar was optional otherwise.

Two letters: HA

But to answer your question based on current PHP, non-prefixed variables 
would conflict with `define()`d constants, which appear as: $foo = 
'abc'.bar;

Ken

ps: sorry, but... heh...
pps: don't use "foo $bar blah" -- use 'foo ' . $bar . ' blah'; or commas:)

---

## #7344 — Christian Schneider — 2004-01-27T10:11:51+00:00

URL: https://externals.io/message/7340#7344 · In reply to: #7342

Ken Tossell wrote:
> pps: don't use "foo $bar blah" -- use 'foo ' . $bar . ' blah'; or commas:)

Why do you say this? I prefer "foo $bar blah".

- Chris

---

## #7345 — Cesare D'Amico — 2004-01-27T10:39:53+00:00

URL: https://externals.io/message/7340#7345 · In reply to: #7344

Alle 11:11, martedì 27 gennaio 2004, Christian Schneider ha scritto:
> Ken Tossell wrote:
> > […]
>
> Why do you say this? I prefer "foo $bar blah".

...let the holy war begin...

;-)

-- 
Cesare D'Amico - boss (@t) cesaredamico (dot) com
http://www.cesaredamico.com        ~       http://www.phpday.it
Il segreto di volare consiste nel gettarti a terra, e sbagliare.
   -- Douglas Adams

---

## #7353 — Andrei Zmievski — 2004-01-27T16:36:57+00:00

URL: https://externals.io/message/7340#7353 · In reply to: #7344

> Why do you say this? I prefer "foo $bar blah".

Because it's faster.

- Andrei

---

## #7355 — Christian Schneider — 2004-01-27T16:43:02+00:00

URL: https://externals.io/message/7340#7355 · In reply to: #7353

Andrei Zmievski wrote:
> 
> > […]
> 
> Because it's faster.

Ok, that's interesting but irrelevant for most of my code. Readability 
is a higher priority in most cases.

Thanks for pointing this out,
- Chris

---

## #7361 — Sterling Hughes — 2004-01-27T17:04:27+00:00

URL: https://externals.io/message/7340#7361 · In reply to: #7355

> Andrei Zmievski wrote:
> > […]
> 
> Ok, that's interesting but irrelevant for most of my code. Readability 
> is a higher priority in most cases.
> 
> Thanks for pointing this out,

If you use a compiler cache like apc, this performance hit will be
totally removed as the optimizer compiles both representations into the
same format.

-sterling

-- 
"Reductionists like to take things apart.  The rest of us are
 just trying to get it together."
    - Larry Wall, Programming Perl, 3rd Edition
