Sunday, 15 August 2010

javascript - Why Do I Get Unexpected " T_ENCAPSED_AND_WHITESPACE Etc. On Short String? -



javascript - Why Do I Get Unexpected " T_ENCAPSED_AND_WHITESPACE Etc. On Short String? -

i understand there @ play here not aware of, cannot understand how can getting next error:

parse error: syntax error, unexpected '' (t_encapsed_and_whitespace), expecting identifier (t_string) or variable (t_variable) or number (t_num_string) in f:\software development\****\htdocs\pages\home2.php on line 17

all 6 of next lines throw error when executed. purpose output array values javascript.

echo "$title['{$line}'] = {$get['title']};"; echo "$content['{$line}'] = {$get['content']};"; echo "$islink['{$line}'] = {$get['islink']};"; echo "$linktext['{$line}'] = {$get['linktext']};"; echo "$linkurl['{$line}'] = {$get['linkurl']};"; echo "$path['{$line}'] = {$get['path']};";

the $get php array storing mysqli_fetch_array(). want know causing error above in code, uses single origin , end quote, , how prevent it. aware flagged duplicate, many questions on topic have, none in big sample topics have been able me.

you want:

"\$title['{$line}'] ...

or:

"\$title['$line'] ...

double-quoted strings expand variables, php seeing "$title ... php variable, followed appears array syntax; it's syntax error not set array syntax curly braces wrapped around in double-quoted string, hence error.

from manual:

the complex syntax can recognised curly braces surrounding expression.

if dollar sign ($) encountered, parser greedily take many tokens possible form valid variable name. enclose variable name in curly braces explicitly specify end of name.

array references require complex syntax.

see: http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing

javascript php

No comments:

Post a Comment