SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error I can't explain.

    Error Code:
    Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /home/mynacfa/public_html/plans1.php on line 49
    Code Segment: Line 49 marked by asterisks
    PHP Code:
        while($main mysql_fetch_array($get_data)){  
            
    $i_EFC_f $main[i_EFC_f]; 
            
    $i_EFC_i $main[i_EFC_i]; 
            
    $a_EFC_f $main[a_EFC_f]; 
            
    $a_EFC_i $main[a_EFC_i]; 
            
    $ann_f $main[ann_f]; 
            
    $ann_i $main[ann_i]; 
            $
    4_f $main[4_f];  *******
            $
    4_i $main[4_i];
            
    $pb_1 $main[pb_1];
            
    $pb_2 $main[pb_2];
        } 
    So I got no idea whatsoever. I really don't see the problem. This isn't one of those stupid "Can't name a variable starting with a number" rules like in javascript is it? The information had to be submitting with php and that went off fine using the same variable names.
    Last edited by aspen; Jul 11, 2001 at 11:06.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Variable names cannot start with numbers. I'm pretty sure this is the case with many languages (Java, C, C++, etc).

  3. #3
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup, that was it.... I hate that rule. It always used to mess me up in js, I didn't know it was a rule in php too.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  4. #4
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As this rule applies to every programming language I have used (except VB - I can't say that I know whether it applies to VB) - there must be some reason for this. There must be some underlying computer architecture reason for why a compiler will not accept a variable who's name begins with a digit. It would be interesting to know why this is.

    <<edited>>

    This page gives a hint: http://www.ladysharrow.ndirect.co.uk.../chapter_2.htm

    Code:
                 1 When the assembler looks at something it needs to know
                 whether it is a name or a number. Is 'A7' a name or a hex number?
                 Is '3D' a name or a number? To solve this problem, all assemblers
                 and all compilers insist that -> if the first character is a
                 number, it's a number; if the first character is not a number, it
                 is not a number. That is why you can't start a variable name with
                 a number.
    And the flip-side to this is that hex numbers must start with a numeral:
    Code:
     4. A hex number. A hex number must start with a number, so if the
                 highest digit is A - F, there must be a 0 in front.{1} b77h is
                 illegal, 0b77h is legal.
    I learn something every day
    Last edited by freakysid; Jul 11, 2001 at 11:32.

  5. #5
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in something like js without a variable identifier I can see it perhaps. But I don't see why it can't recognize the variable identifier ($) and realize that what comes after that is a variable name.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  6. #6
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is an interesting question. I remember reading in an faq or in the man or somewhere that PHP was originally written in Perl, but I am assuming that since version 3, the PHP interpreter (the "Zend Engine") is written in C. I'm guessing at that because there seems to be a lot of the C API and standard libraries showing through in PHP. I'm guessing that PHP is just throwing some thin wrappers around C standard functions. So this may explain why PHP follows the C rules with naming variables. It would be interesting to know more about this.


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
  •