You are here: Re: Cannot use "-" in variable names? « PHP Programming Language « IT news, forums, messages
Re: Cannot use "-" in variable names?

Posted by Malcolm Dew-Jones on 12/09/05 22:19

Janwillem Borleffs (jw@jwscripts.com) wrote:
: ross wrote:
: > I understand that the "-" sign is seen as an operator.
: > is there a way to get around this? I need to have "-" in variable
: > names.

: Why a hyphen and not an underscore? Anyways if you insist:

: ${'super-man'} = 100;
: print ${'super-man'};

Technically correct, and good to know for understanding php.

However the original poster should please notice that either of the
following two would normally be much better in a program

$super_heroes['super-man'] = 100;

OR

$super_man = 100;

The best style would depend on the circumstances. In a game of "superman
vs kryptonite" the latter would likely be appropriate.

In a game of "how many super heroes do your friends know" then the former
would likely be best.

$0.10

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация