How to fix Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE or '$

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • santhanalakshmi
    New Member
    • May 2009
    • 147

    How to fix Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE or '$

    Hi,
    I dont know, what mistake i made in my code.

    Code:
    [B]test1.php[/B]
    <?php
    namespace MyNameSpace;
    class A
    {
      public function B()
      {
          echo "san";
      }
    }
    ?>
    Code:
    [B]test2.php[/B]
    <?php
    include('test1.php');
    $test=new MyNameSpace::A();
    $test->B();
    ?>

    http://localhost/test2.php
    Error:
    Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE or '$' in C:\xampp\htdocs \MyNameSpace\te st2.php on line 3
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    The namespace separator is the backslash.

    See the documentation: http://uk2.php.net/manual/en/languag....rationale.php

    Comment

    Working...