Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #2990
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Richard Damon <news.x.richarddamon@xoxy.net> |
| Newsgroups | comp.lang.php |
| Subject | Re: Why Can't I "define" a Value for a Subscript? |
| Date | Sun, 28 Aug 2011 20:26:09 -0400 |
| Organization | A noiseless patient Spider |
| Lines | 58 |
| Message-ID | <j3emb2$sql$1@dont-email.me> (permalink) |
| References | <Cvw6q.176718$k33.110045@en-nntp-13.dc1.easynews.com> <j3e62a$p8k$1@dont-email.me> <uYx6q.176728$k33.132762@en-nntp-13.dc1.easynews.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Mon, 29 Aug 2011 00:26:10 +0000 (UTC) |
| Injection-Info | mx04.eternal-september.org; posting-host="j1pFZldDJZ4VtkJ1t0sbMg"; logging-data="29525"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CoSQJPbTCxVZ5xuczhQyvq60IimM1FFk=" |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0) Gecko/20110812 Thunderbird/6.0 |
| In-Reply-To | <uYx6q.176728$k33.132762@en-nntp-13.dc1.easynews.com> |
| Cancel-Lock | sha1:x0SaBCkSJewM68BAxEq7HklZ15Q= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.php:2990 |
Show key headers only | View raw
On 8/28/11 4:57 PM, eBob.com wrote:
>
> "Chuck Anderson" <cycletourist@invalid.invalid> wrote in message
> news:j3e62a$p8k$1@dont-email.me...
>> eBob.com wrote:
>>> I am working with some csv files. To make the program more
>>> maintainable and more self-documenting I "define" values to use as
>>> subscripts; e.g. ...
>>>
>>> define('SS2KEY',0);
>>>
>>> BUT, whereas this produces what I expected ...
>>>
>>> echo "we have a match - key: $file2cols[0]\n";
>>>
>>> ... this does not ...
>>>
>>> echo "we have a match - key: $file2cols[SS2KEY]\n";
>>>
>>> I see the other text but no value is substitited for $file2cols[SS2KEY]
>>>
>>> I've wasted so much time on this. Why can't I define constants to use
>>> as subscripts?
>>>
>>> Thanks, Bob
>>
>> Php does not look for constants within double quotes.
>>
>> http://www.php.net/manual/en/language.types.array.php
>> (Look for "Array do's and don'ts" - scroll down a wee bit for examples)
>>
>> --
>> *****************************
>> Chuck Anderson • Boulder, CO
>> http://cycletourist.com
>> Turn Off, Tune Out, Drop In
>> *****************************
>
> OUCH!!!!!!! But thanks! Now if I can only remember this "feature".
>
> Thanks, Bob
To understand why it is this way, just think about this program:
define('Hello', 'Goodbye cruel');
echo "Hello World";
Just looking at the echo statement, you should know what is printed, and
not need to scan the whole program to make sure nothing is going to
change your string.
if you see
echo "Hello $name";
the $ make it clear that the following will be substituted so there is
no surprise (if you know the language rules).
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why Can't I "define" a Value for a Subscript? "eBob.com" <eBob.com@totallybogus.com> - 2011-08-28 15:18 -0400
Re: Why Can't I "define" a Value for a Subscript? PS "eBob.com" <eBob.com@totallybogus.com> - 2011-08-28 15:36 -0400
Re: Why Can't I "define" a Value for a Subscript? PS Norman Peelman <npeelman@cfl.rr.com> - 2011-08-28 15:53 -0400
Re: Why Can't I "define" a Value for a Subscript? PS "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-08-29 13:43 +0200
Re: Why Can't I "define" a Value for a Subscript? Denis McMahon <denis.m.f.mcmahon@gmail.com> - 2011-08-28 19:43 +0000
Re: Why Can't I "define" a Value for a Subscript? Chuck Anderson <cycletourist@invalid.invalid> - 2011-08-28 13:48 -0600
Re: Why Can't I "define" a Value for a Subscript? "eBob.com" <eBob.com@totallybogus.com> - 2011-08-28 16:57 -0400
Re: Why Can't I "define" a Value for a Subscript? Richard Damon <news.x.richarddamon@xoxy.net> - 2011-08-28 20:26 -0400
Re: Why Can't I "define" a Value for a Subscript? "Peter H. Coffin" <hellsop@ninehells.com> - 2011-08-28 15:02 -0500
Re: Why Can't I "define" a Value for a Subscript? A.Reader <anonymously@example.com> - 2011-08-30 09:55 -0400
Re: Why Can't I "define" a Value for a Subscript? Jerry Stuckle <jstucklex@attglobal.net> - 2011-08-30 11:09 -0400
csiph-web