SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast Adam E's Avatar
    Join Date
    Apr 2004
    Location
    Australia
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrays and strings

    Good Afternoon everyone,

    I was just wondering...I think the following example will produce an error

    PHP Code:

    $string 
    = <<<EOD
    <html>$file['page']</html>
    EOD; 
    Is there a another way to do that without going like this...

    PHP Code:

    $page 
    $file['page']
    $string = <<<EOD
    <html>$page</html>
    EOD; 
    Thanks
    Adam

  2. #2
    SitePoint Enthusiast bind727's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Alberta
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That shouldn't produce an error.

    If it does you can always use a regular string
    PHP Code:
    [color=#0000bb]$string [color=#007700]= "[/color][color=#0000bb]<html>".$file[/color][color=#007700][[/color][color=#0000bb]'page'[/color][color=#007700]]."[/color][color=#0000bb]</html>[color=#000000]";[/color][/color] 
    [/color]
    +---------------------------+
    Joel Pittet | Web Developer
    www.JoelPittet.com
    +---------------------------+

  3. #3
    SitePoint Enthusiast bind727's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Alberta
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wonder how that color thing got on my last post I just used php tags.
    +---------------------------+
    Joel Pittet | Web Developer
    www.JoelPittet.com
    +---------------------------+

  4. #4
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
     $string = <<<EOD
    <html>{$file['page']}</html>
    EOD; 
    Use {} to concatenate in heredocs.

  5. #5
    SitePoint Wizard Dangermouse's Avatar
    Join Date
    Oct 2003
    Posts
    1,024
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    {} Arent concatenation operators, its called the complex/simple syntax

    Examples here http://php.planetmirror.com/manual/e...arsing.complex

  6. #6
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah? Well it works doesn't it?

  7. #7
    SitePoint Wizard Dangermouse's Avatar
    Join Date
    Oct 2003
    Posts
    1,024
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wasnt disputing that

  8. #8
    SitePoint Enthusiast Adam E's Avatar
    Join Date
    Apr 2004
    Location
    Australia
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lol,

    Thanks guys!
    Adam


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •