php-general Digest 18 Nov 2012 20:29:42 - Issue 8046
Topics (messages 319731 through 319734):
Re: Variables with - in their name
319731 by: Nathan Nobbe
319732 by: Ashley Sheridan
319733 by: tamouse mailing lists
globbed includes?
319734 by: tamouse mailing lists
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
--
---BeginMessage---
On Sat, Nov 17, 2012 at 11:09 PM, Ron Piggott
ron.pigg...@actsministries.org wrote:
I have made the following variable in a form: (I am referring the
select )
?php
$row['promo_code_prefix'] = 42;
$row['promo_code_suffix'] = 2;
echo select name=\distributor- . $row['promo_code_prefix'] . - .
$row['promo_code_suffix'] . \ style=\text-align: center;\\r\n;
?
It could be wrote:
?php
echo $distributor-42-2;
?
Only PHP is treating the hyphen as a minus sign --- which in turn is
causing a syntax error.
How do I retrieve the value of this variable and over come the “minus”
sign that is really a hyphen?
php ${distributor-42-2} = 5;
php echo ${distributor-42-2};
5
I think that's it.
-nathan
---End Message---
---BeginMessage---
On Sun, 2012-11-18 at 01:37 -0700, Nathan Nobbe wrote:
On Sat, Nov 17, 2012 at 11:09 PM, Ron Piggott
ron.pigg...@actsministries.org wrote:
I have made the following variable in a form: (I am referring the
select )
?php
$row['promo_code_prefix'] = 42;
$row['promo_code_suffix'] = 2;
echo select name=\distributor- . $row['promo_code_prefix'] . - .
$row['promo_code_suffix'] . \ style=\text-align: center;\\r\n;
?
It could be wrote:
?php
echo $distributor-42-2;
?
Only PHP is treating the hyphen as a minus sign --- which in turn is
causing a syntax error.
How do I retrieve the value of this variable and over come the “minus”
sign that is really a hyphen?
php ${distributor-42-2} = 5;
php echo ${distributor-42-2};
5
I think that's it.
-nathan
I'd just try and avoid the hyphens in the variable names in the first
place if you can. Can you guarantee that everyone working on this system
will know when to encapsulate the variables in braces?
Thanks,
Ash
http://www.ashleysheridan.co.uk
---End Message---
---BeginMessage---
On Sun, Nov 18, 2012 at 5:12 AM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:
On Sun, 2012-11-18 at 01:37 -0700, Nathan Nobbe wrote:
On Sat, Nov 17, 2012 at 11:09 PM, Ron Piggott
ron.pigg...@actsministries.org wrote:
I have made the following variable in a form: (I am referring the
select )
?php
$row['promo_code_prefix'] = 42;
$row['promo_code_suffix'] = 2;
echo select name=\distributor- . $row['promo_code_prefix'] . - .
$row['promo_code_suffix'] . \ style=\text-align: center;\\r\n;
?
It could be wrote:
?php
echo $distributor-42-2;
?
Only PHP is treating the hyphen as a minus sign --- which in turn is
causing a syntax error.
How do I retrieve the value of this variable and over come the “minus”
sign that is really a hyphen?
php ${distributor-42-2} = 5;
php echo ${distributor-42-2};
5
I think that's it.
-nathan
I'd just try and avoid the hyphens in the variable names in the first
place if you can. Can you guarantee that everyone working on this system
will know when to encapsulate the variables in braces?
Thanks,
Ash
http://www.ashleysheridan.co.uk
Agreed.
From http://www.php.net/manual/en/language.variables.basics.php :
Variable names follow the same rules as other labels in PHP. A
valid variable name starts with a letter or underscore, followed
by any number of letters, numbers, or underscores.
The ${var} circumvents this (somewhat), but in the case above, it
would be better to avoid the dashes and use underscores.
---End Message---
---BeginMessage---
There are certain times I'd like to include all files in a given
directory (such as configuration stuff that is split out by type, a la
apache conf.d). Anyone have something handy that implements that?
---End Message---