SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Weird parse error

    PHP Code:
    <?php

    class page_layout
    {

        function 
    header$page_header )
        {
                global 
    $INFO;
                
    $skin_name 'default';

                return <<<EOF
                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

                <html xmlns="http://www.w3.org/1999/xhtml">

                <head>

                    <title>
    {$page_header}</title>

                    <meta http-equiv="Content-Type" content="text/html;
                    charset=iso-8859-1" />

                    <link rel="shortcut icon" href="/favicon.ico" />

                    <!-- Style Sheet -->
                    <link rel="stylesheet" type="text/css" href="skins/
    {$skin_name}/style.css" />


                    <script language="javascript" type="text/javascript">

                    function mirage(choice)
                    {
                        if( !document.getElementById ) return false;

                        var obj = document.getElementById("lside");
                        var obj_sec = document.getElementById("content");
                        var obj_thi = document.getElementById("rside");
                        var layouthelpl = document.getElementById("layouthelpl");

                        if( choice == "website" )
                        {
                            obj.style.display = "block";
                            obj_sec.style.margin = "0px 200px 0 200px";
                            obj_thi.style.display = "block";
                            layouthelpl.style.background = "url(skins/
    {$skin_name}/graphics/left_nav_bg.jpg) repeat-y left";
                        }
                        else
                        {
                            obj.style.display = "none";
                            obj_sec.style.margin = "0 7px 0 7px";
                            obj_thi.style.display = "none";
                            layouthelpl.style.background = "transparent";
                        }
                    }
                    </script>
                </head>

                <body>

                <div id="banner">
                    <div id="header_left"><img src="skins/
    {$skin_name}/graphics/header_left.jpg" alt="{$INFO['site_name']}" /></div>
                    <div id="header_right"><img src="skins/
    {$skin_name}/graphics/header_right.jpg" alt="{$INFO['site_name']}" /></div>
                </div>

                  <div id="layouthelpl">
                      <div id="container">
                EOF;

            }


            function footer()
            {
                global 
    $INFO;

                return <<<EOF
                    <div id="footer"><div id="footer_left"><img src="skins/
    {$skin_name}/graphics/footer_left.jpg" alt="{$INFO['site_name']}" /></div>
                             <div id="footer_right"><img src="skins/
    {$skin_name}/graphics/footer_right.jpg" alt="{$INFO['site_name']}" /></div>
                             <div id="copyinfo">Copyright &copy; 2000-2003 Wild Fire Games | All Rights Reserved</div>
                    </div>
                    </body>
                    </html>
                EOF;
            }


            function left_nav_begin()
            {
                return <<<EOF
                    <div id="lside">
                    <form method="post" action="self.php"><input id="textfield" type="text" /><input id="submitbutton" type="submit" name="submit" value="Search" /></form>
                EOF;
            }


            function right_nav_begin()
            {
                return <<<EOF
                    <div id="rside">
                EOF;
            }


            function end_div()
            {
                return <<<EOF
                    </div>
                EOF;
            }


            function lrnav_heading( 
    $item );
            {
                return <<<EOF
                    <h3><img src="skins/
    {$skin_name}/graphics/{$item}.jpg" alt="{$item}" /></h3>
                EOF;
            }


            function start_list()
            {
                return <<<EOF
                    <ul>
                EOF;
            }

            function end_list()
            {
                return <<<EOF
                    </ul>
                EOF;
            }


            function lrnav_listitem( 
    $itemname$link )
            {
                return <<<EOF
                    <li><a href="
    {$link}" title="{$itemname}">{$itemname}</a></li>
                EOF;
            }


            function start_sitenav( 
    $id )
            {
                return <<<EOF
                    <div class="sitenavigation" id="top">
                EOF;
            }


            function sitenav_listitem( 
    $itemname$link )
            {
                return <<<EOF
                    <li>&raquo;&nbsp;<a href="
    {$link}" title="{$itemname}">{$itemname}</a></li>
                EOF;
            }


            function start_pagenav()
            {
                return <<<EOF
                    <div class="pagenavigation">
                EOF;
            }


            function pagenav_listitem( 
    $itemname$link )
            {
                return <<<EOF
                    <li>&raquo;&nbsp;<a href="
    {$link}" title="{$itemname}">{$itemname}</a></li>
                EOF;
            }


            function start_content( 
    $page_heading )
            {
                return <<<EOF
                    <div id="contentcont">
                        <h2><span>
    {$page_heading}</span></h2>
                        <div class="contentbar"></div>
                EOF;
        }


    } // end class

    ?>
    I am getting a parse error "unexpected $" on the last line of this code (187). Does anybody have a clue ?

    PS: Feel free to use this class for your own needs.

  2. #2
    SitePoint Zealot Selatos's Avatar
    Join Date
    Aug 2002
    Location
    USA
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe you are missing 1 closing bracket, "}". Add it at the end, and it should work.
    I've gotten this error before, and i've found that i was always missing a bracket somewhere, but the parse error seems to have nothing to do with brackets.

    function start_content( $page_heading )
    {

    return <<<EOF
    <div id="contentcont">
    <h2><span>
    {$page_heading}
    </span></h2>
    <div class="contentbar"></div>
    EOF;

    }
    }
    } // end class

  3. #3
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, nope didn't solve it.

  4. #4
    Thinking about Visual Thinking
    Join Date
    May 2003
    Location
    back in South Africa
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DarkAngelBGE
    I am getting a parse error "unexpected $" on the last line of this code (187). Does anybody have a clue ?
    You are using the heredoc statement incorrectly (no offence ment ):

    Quote Originally Posted by PHP Manual
    The closing identifier must begin in the first column of the line. Also, the identifier used must follow the same naming rules as any other label in PHP: it must contain only alphanumeric characters and underscores, and must start with a non-digit character or underscore.
    and
    Quote Originally Posted by PHP Manual
    It is very important to note that the line with the closing identifier contains no other characters, except possibly a semicolon ';'. That means especially that the identifier may not be indented, and there may not be any spaces or tabs after or before the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by your operating system. This is \r on Macintosh for example.

    If this rule is broken and the closing identifier is not "clean" then it's not considered to be a closing identifier and PHP will continue looking for one. If in this case a proper closing identifier is not found then a parse error will result with the line number being at the end of the script.
    Take notice of the last paragraph! See Strings.

    Viele Grüße aus dem Süden nach Berlin!

  5. #5
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PS: Feel free to use this class for your own needs.
    Thanks but I couldn't

    1) Your using GLOBALs, and
    2) IMO you shouldn't have any markup in a class

    Though I do know how convienent it is... I just cannot understand why you need to use OOP for what basically amounts to a template ?

    Just my thoughts really I suppose.

  6. #6
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @Stefano, thanks. Always having problems with the heredoc syntax. I just woke up and changed the code, no time yet to test it.

    Viele Grüße aus dem Süden nach Berlin!
    Viele Grüße zurück nach Südafrika.

    @the doctor p): I use the same core code for my skin system which invision power board uses. This is due to me being under some time contraints. Once the whole system works I may recode it so it doesn't use globals. Having an object that represents the whole markup for the page layout is very nice IMO.

    So start using my class finally.

  7. #7
    Thinking about Visual Thinking
    Join Date
    May 2003
    Location
    back in South Africa
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DarkAngelBGE
    Always having problems with the heredoc syntax. I just woke up and changed the code, no time yet to test it.
    Just let us know, if it's up and running now .

  8. #8
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, it is working now.

    Putting it bold so everybdy notices, especially Setafno.

    Thanks.

  9. #9
    Thinking about Visual Thinking
    Join Date
    May 2003
    Location
    back in South Africa
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ...

  10. #10
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Stefano, you speaking German then ? If so, how come you are in SA ?

  11. #11
    Thinking about Visual Thinking
    Join Date
    May 2003
    Location
    back in South Africa
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See my biography ... after 19 years in Italy and 15 years in Germany I'm enjoying life here in SA as an expatriate. Time will tell where the next post will be ...

    Ist doch nicht schlecht für eine deutsche Fa. im Ausland tätig zu sein, oder?

    Combining business with pleasure ... that's the key .

  12. #12
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well said !

    Gut gesagt.


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
  •