Parse Error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike Schumann

    Parse Error

    I have the following PHP code:

    <?php
    class zen_categories_ ul_generator {
    var $root_category_ id = 0,
    $max_level = 6,
    $data = array(),
    $root_start_str ing = '',
    $root_end_strin g = '',
    $parent_start_s tring = '',
    $parent_end_str ing = '',

    $child_start_st ring = '<li%s>',
    $child_end_stri ng = '</li>'."\n",

    $spacer_string = '',
    $spacer_multipl ier = 1;

    etc..........

    I am getting a parse error in this line:

    $child_end_stri ng = '</li>'."\n",

    PHP doesn't like the period character.

    I am running PHP Ver 4.4.2

    Does anyone have any ideas what is going on?

    Thanks,
    --
    Mike Schumann


  • Jerry Stuckle

    #2
    Re: Parse Error

    Mike Schumann wrote:[color=blue]
    > I have the following PHP code:
    >
    > <?php
    > class zen_categories_ ul_generator {
    > var $root_category_ id = 0,
    > $max_level = 6,
    > $data = array(),
    > $root_start_str ing = '',
    > $root_end_strin g = '',
    > $parent_start_s tring = '',
    > $parent_end_str ing = '',
    >
    > $child_start_st ring = '<li%s>',
    > $child_end_stri ng = '</li>'."\n",
    >
    > $spacer_string = '',
    > $spacer_multipl ier = 1;
    >
    > etc..........
    >
    > I am getting a parse error in this line:
    >
    > $child_end_stri ng = '</li>'."\n",
    >
    > PHP doesn't like the period character.
    >
    > I am running PHP Ver 4.4.2
    >
    > Does anyone have any ideas what is going on?
    >
    > Thanks,[/color]

    The period is fine. But the comma at the end isn't.

    If you really do have a semicolon at the end, look for mismatched single or
    double quotes on a previous line.


    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Mike Schumann

      #3
      Re: Parse Error

      Why is the comma at the end of the line any different than the lines before
      it, which parsed just fine?

      Mike Schumann

      "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
      news:gsadnSYbcN T31KvZnZ2dnUVZ_ sSdnZ2d@comcast .com...[color=blue]
      > Mike Schumann wrote:[color=green]
      >> I have the following PHP code:
      >>
      >> <?php
      >> class zen_categories_ ul_generator {
      >> var $root_category_ id = 0,
      >> $max_level = 6,
      >> $data = array(),
      >> $root_start_str ing = '',
      >> $root_end_strin g = '',
      >> $parent_start_s tring = '',
      >> $parent_end_str ing = '',
      >>
      >> $child_start_st ring = '<li%s>',
      >> $child_end_stri ng = '</li>'."\n",
      >>
      >> $spacer_string = '',
      >> $spacer_multipl ier = 1;
      >>
      >> etc..........
      >>
      >> I am getting a parse error in this line:
      >>
      >> $child_end_stri ng = '</li>'."\n",
      >>
      >> PHP doesn't like the period character.
      >>
      >> I am running PHP Ver 4.4.2
      >>
      >> Does anyone have any ideas what is going on?
      >>
      >> Thanks,[/color]
      >
      > The period is fine. But the comma at the end isn't.
      >
      > If you really do have a semicolon at the end, look for mismatched single
      > or double quotes on a previous line.
      >
      >
      > --
      > =============== ===
      > Remove the "x" from my email address
      > Jerry Stuckle
      > JDS Computer Training Corp.
      > jstucklex@attgl obal.net
      > =============== ===[/color]


      Comment

      • Jerry Stuckle

        #4
        Re: Parse Error

        Mike Schumann wrote:[color=blue]
        > Why is the comma at the end of the line any different than the lines before
        > it, which parsed just fine?
        >
        > Mike Schumann
        >
        > "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
        > news:gsadnSYbcN T31KvZnZ2dnUVZ_ sSdnZ2d@comcast .com...
        >[color=green]
        >>Mike Schumann wrote:
        >>[color=darkred]
        >>>I have the following PHP code:
        >>>
        >>><?php
        >>> class zen_categories_ ul_generator {
        >>> var $root_category_ id = 0,
        >>> $max_level = 6,
        >>> $data = array(),
        >>> $root_start_str ing = '',
        >>> $root_end_strin g = '',
        >>> $parent_start_s tring = '',
        >>> $parent_end_str ing = '',
        >>>
        >>> $child_start_st ring = '<li%s>',
        >>> $child_end_stri ng = '</li>'."\n",
        >>>
        >>> $spacer_string = '',
        >>> $spacer_multipl ier = 1;
        >>>
        >>>etc......... .
        >>>
        >>>I am getting a parse error in this line:
        >>>
        >>> $child_end_stri ng = '</li>'."\n",
        >>>
        >>>PHP doesn't like the period character.
        >>>
        >>>I am running PHP Ver 4.4.2
        >>>
        >>>Does anyone have any ideas what is going on?
        >>>
        >>>Thanks,[/color]
        >>
        >>The period is fine. But the comma at the end isn't.
        >>
        >>If you really do have a semicolon at the end, look for mismatched single
        >>or double quotes on a previous line.
        >>
        >>[/color][/color]

        Your problem is that the period has a higher precedence than the comma.
        Therefore it tries to end the variable definition at the period, overriding the
        comma.

        I don't like stringing a lot of variables on multiple lines like this - and this
        is one of the reasons why (another is just style). Define them as:

        var $root_category_ id = 0;
        var $max_level = 6;
        var $data = array();
        var $root_start_str ing = '';
        var $root_end_strin g = '';
        var $parent_start_s tring = '';
        var $parent_end_str ing = '';

        var $child_start_st ring = '<li%s>';
        var $child_end_stri ng = '</li>'."\n";

        var $spacer_string = '';
        var $spacer_multipl ier = 1;

        and your problem goes away.

        You might also get by with:

        $child_end_stri ng = ('</li>'."\n"),

        but I haven't tried it.

        (P.S. Please don't top post).


        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        Working...