You are here: Re: Accessing superglobal elements « PHP Programming Language « IT news, forums, messages
Re: Accessing superglobal elements

Posted by Rik Wasmus on 11/22/07 20:47

On Thu, 22 Nov 2007 21:32:40 +0100, Michaelp <michaelp@hio.no> wrote:

> Hello!
>
> I see that I can access a superglobal element using the index this
> way:
>
> print("<p>$_GET[surname]</p>"); //(element index without any
> delimiters within a double-quotation-mark-delimited string)
>
> But not this way:
>
> print("<p>$_GET['surname']</p>"); //(apostroph-delimited element index
> within a double-quotation-mark-delimited string)
>
> The latter gives me an error message:
> Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
> expecting T_STRING or T_VARIABLE or T_NUM_STRING
>
>
> Why is that? (I cant understand why PHP gets confused by that)

Posted the links only days ago, but here you go:
http://nl2.php.net/manual/en/language.types.string.php#language.types.string.parsing

So, use:
"<p>{$_GET['surname']}</p>"

(Well, actually, don't, unless you're sure you've checked the GET variable
for XSS attacks.
--
Rik Wasmus

 

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

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