heredoc and $_SERVER vars

This is a discussion on heredoc and $_SERVER vars within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, Why can't you insert $_SERVER vars with in a heredoc block? Ex: $str = <<<heredoc $_SERVER['...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-13-2006
Stef
 
Posts: n/a
Default heredoc and $_SERVER vars

Hi,

Why can't you insert $_SERVER vars with in a heredoc block?

Ex:

$str = <<<heredoc

$_SERVER['PATH_TRANSLATED'];

heredoc;

Gives me this error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in *** on line 22

-

What is the logic behind this error?

S

--



Reply With Quote
  #2 (permalink)  
Old 04-13-2006
LetsSurf
 
Posts: n/a
Default Re: heredoc and $_SERVER vars

You can but it would be more like this

$str = <<<HEREDOC
{$_SERVER['PATH_TRANSLATED']}
HEREDOC;

Hope this helps.

Stef wrote:
> Hi,
>
> Why can't you insert $_SERVER vars with in a heredoc block?
>
> Ex:
>
> $str = <<<heredoc
>
> $_SERVER['PATH_TRANSLATED'];
>
> heredoc;
>
> Gives me this error:
>
> Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
> T_STRING or T_VARIABLE or T_NUM_STRING in *** on line 22
>
> -
>
> What is the logic behind this error?
>
> S
>

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:07 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0