SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What this error???

    I am tring out from sitepoint tribune.
    my Page.php is
    PHP Code:
    <?php 
    // Page class 
    class Page 
     
    // Generates the top of the page 
     
    function addHeader($page$title
     { 
       
    $page .= <<<EOD 
    <html
    <
    head
    <
    title>$title</title
    </
    head
    <
    body
    <
    h1 align="center">$title</h1
    EOD
       return 
    $page
     } 

     
    // Generates the bottom of the page 
     
    function addFooter($page$year$copyright
     { 
       
    $page .= <<<EOD 
    <div align="center">&copy$year $copyright</div
    </
    body
    </
    html
    EOD
       return 
    $page
     } 
    }

    ?>
    My test.php is
    PHP Code:
    <?php
    // Initialize the page variable 
    $page ''

    // Add the header to the page 
    $page Page::addHeader($page'A Script Using Static Methods'); 

    // Add something to the body of the page 
    $page.=<<<EOD 
    <p align="center">This page was generated with static class 
    methods</p
    EOD

    // Add the footer to the page 
    $page Page::addFooter($pagedate('Y'), 'Static Designs Inc.'); 

    // Display the page 
    echo $page
    ?>
    in Page.php the error is:
    Parse error: syntax error, unexpected T_SL in d:\www\ujjwal\Page.php on line 7

    in test.php the error is:
    Parse error: syntax error, unexpected T_SL in d:\www\ujjwal\test.php on line 9
    Will you look on the type of error and how can i remove it?
    -::Ujjwal::-
    Visit My Site

  2. #2
    Non-Member St.'s Avatar
    Join Date
    Nov 2004
    Location
    Cloud #9
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its work at my machine.

    Does you write EOD; on start of line?

    EOD;
    or
    ...EOD;
    ?

  3. #3
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know Heredoc string.
    so whatever u have found ,I have written that.
    One more q is I am using apache 2.5.1(Php 5)
    -::Ujjwal::-
    Visit My Site

  4. #4
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by St.
    Its work at my machine.

    Does you write EOD; on start of line?

    EOD;
    or
    ...EOD;
    ?
    Which line in which file?
    -::Ujjwal::-
    Visit My Site

  5. #5
    Non-Member St.'s Avatar
    Join Date
    Nov 2004
    Location
    Cloud #9
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in any file and any line 8)

    there are must noone spaces before EOD; ( if you start string with <<<EOD )

  6. #6
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by St.
    in any file and any line 8)

    there are must noone spaces before EOD; ( if you start string with <<<EOD )
    Means that there is no white space in that class.
    look here
    PHP Code:
    <?php 
    // Page class 
    class Page 
     
    // Generates the top of the page 
     
    function addHeader($page$title
     {
         
    $page .=<<<EOD 
    <html><head><title>$title</title></head><body><h1 align="center">$title</h1>EOD
       return 
    $page
     } 

     
    // Generates the bottom of the page 
     
    function addFooter($page$year$copyright
     { 
       
    $page .= <<<EOD 
    <div align="center">&copy$year $copyright</div
    </
    body
    </
    html>
    EOD
       return 
    $page
     } 
    }

    ?>
    but still i am getting fatal error.
    -::Ujjwal::-
    Visit My Site


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
  •