The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

installing slim in index.php is throwing unexpected T string error

shawna 's Avatar

shawna

19 Mar, 2014 09:04 PM

On these two lines:
\Slim\Slim::registerAutoloader(); $app = new \Slim\Slim();

I am getting these errors:
Unexpected character in input: '\' (ASCII=92) state=1 in public_html/rest/v1/index.php on line 9 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in public_html/rest/v1/index.php on line 9
Parse error: syntax error, unexpected T_STRING in
public_html/rest/v1/index.php on line 9

  1. 1 Posted by shawna on 19 Mar, 2014 09:18 PM

    shawna 's Avatar

    I forgot to say i do have this line before this:
    require '../libs/Slim/Slim.php';

  2. Support Staff 2 Posted by Andrew Smith on 20 Mar, 2014 09:59 PM

    Andrew Smith's Avatar

    This would seem like a server specific issue, try omitting the \ before Slim\Slim and see if that makes a difference.

  3. 3 Posted by Arie on 11 Apr, 2014 02:47 PM

    Arie's Avatar

    I'm having the same problem.

    The output after installing is:



    Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/websites/domains/wijhoudenvanvoetbal.nl/public_html/rest-api/v1/index.php on line 7



    Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/websites/domains/wijhoudenvanvoetbal.nl/public_html/rest-api/v1/index.php on line 7



    Parse error: syntax error, unexpected T_STRING in /home/websites/domains/wijhoudenvanvoetbal.nl/public_html/rest-api/v1/index.php on line 7

    When I omit the \ in line 7 ( \Slim\Slim::registerAutoloader(); into Slim\Slim::registerAutoloader(); ) I get this output:



    Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/websites/domains/wijhoudenvanvoetbal.nl/public_html/rest-api/v1/index.php on line 7



    Parse error: syntax error, unexpected T_STRING in /home/websites/domains/wijhoudenvanvoetbal.nl/public_html/rest-api/v1/index.php on line 7

    One unexpected error less but still one to many ........ ;-)

    On line 7 I have now Slim\Slim::registerAutoloader();

    Any idea what still goes wrong?

    Kind regards,

    Arie

  4. Support Staff 4 Posted by Andrew Smith on 11 Apr, 2014 03:17 PM

    Andrew Smith's Avatar

    My guess is your are using a PHP version less than 5.3, as PHP namespace was introduced in PHP 5.3, anything below that won't work. Slim requires that you have PHP 5.3 minimum.

  5. 5 Posted by Arie on 14 Apr, 2014 07:49 AM

    Arie's Avatar

    You are right, We are using right now 5.2.17 so I'm going to checked how to upgrade PHP to 5.3

  6. 6 Posted by Mike Wunderlich on 18 Apr, 2014 02:34 AM

    Mike Wunderlich's Avatar

    Ugh. I'm so dumb. Did all my dev on a 5.3 server, production is 5.2.17

    What are my options here? I don't have the ability to update the PHP on my server to 5.3 (managed server). Is there an older version of Slim that I can use? I'm only using GET routes currently.

  7. 7 Posted by Haijin on 18 Apr, 2014 09:55 PM

    Haijin's Avatar

    Ask your hosting provider to upgrade to 5.3. If that does not work use a VPS service like DigitalOcean or any other.

  8. Support Staff 8 Posted by Andrew Smith on 21 Apr, 2014 10:43 AM

    Andrew Smith's Avatar

    Mike you can roll back to pre 2.0 and you should be fine.

  9. 9 Posted by Mike Wunderlich on 21 Apr, 2014 04:05 PM

    Mike Wunderlich's Avatar

    FYI, if you host on 1and1.com (I do) you can "tune" your PHP version using .htaccess

    I found that I could go up to 5.4 which works flawlessly with the slim stuff as I had done on my dev server.

    Whew!

    So just wanted to leave this for any other 1and1.com customers

  10. 10 Posted by qiyobeta on 03 May, 2017 08:11 AM

    qiyobeta's Avatar

    I have seeing many errors in installing drupal.
    http://newbodydietplan.com/

  11. 11 Posted by cutotome on 04 May, 2017 07:28 AM

    cutotome's Avatar

    I also getting this error again and again.
    http://exbackbook.com/

  12. 12 Posted by nuvs on 06 Jun, 2017 11:03 AM

    nuvs's Avatar

    I also want to know the method to install slim in index.php.
    In-Depth Love Commands Review - lovecodesbook

  13. 13 Posted by gqws on 07 Jun, 2017 10:54 AM

    gqws's Avatar

    I would also like to know about this. Take a time and find more resources

  14. 14 Posted by hiws on 08 Jun, 2017 08:44 AM

    hiws's Avatar

    I also want to know the steps of installing slim in index.php.
    Find out about ex factor guide refund

  15. 15 Posted by xibuluya on 29 Sep, 2017 07:25 PM

    xibuluya's Avatar

    Errors are very much popular
    http://penisenlargementbiblebook.com/

  16. 16 Posted by vuqifure on 30 Sep, 2017 08:14 PM

    vuqifure's Avatar

    When my wife got angry on me she throws things on me.
    http://getbiggerdicknaturally.com/

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac