You are here: Re: evaluate expression inside array « PHP Programming Language « IT news, forums, messages
Re: evaluate expression inside array

Posted by Umberto Salsi on 12/17/83 11:55

"amygdala" <noreply@noreply.com> wrote:

> The full array is this (part of a session class):
>
> private $config = array(
> 'sessionTable' => DB_TABLE_SESSIONS,
> 'userTable' => DB_TABLE_USERS,
> 'persistentMaxTime' => 60*60*24*30,
> 'sessionMaxInactive' => 60*30,
> 'regenerateId' => true,
> 'idRegenerationInterval' => 10,
> 'cookieName' => 'PHPSESSION',
> 'cookiePath' => '/',
> 'checkIp' => true,
> 'checkAgent' => true
> );
>
> which yields the error:
>
> Parse error, parse error, unexpected '*', expecting ')' on line 49 (which is
> the line of 'persistentMaxTime')

That's an invalid syntax: the default value of a class property must be
a static_scalar, that is a simple number, a string or an array of these
items. Other expressions are not allowed.
Here is a chunk from the EBNF syntax of PHP 5:

static_scalar = common_scalar
| T_STRING
| "+" static_scalar
| "-" static_scalar
| "array" "(" [static_array_pair_list] ")"
| static_class_constant ;

static_array_pair_list = static_array_pair { "," static_array_pair } [","] ;

static_array_pair = static_scalar ["=>" static_scalar] ;

Check the official BNF syntax Zend/zend_language_parser.y
(http://www.icosaedro.it/articoli/php-syntax-yacc.txt)
or the equivalent EBNF syntax translated by me from that file
(http://www.icosaedro.it/articoli/php-syntax-ebnf.txt)

So, expressions like "60*30" aren't allowed. Use "1800" instead.

Regards,
___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it

 

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

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