Laravel no servidor Locaweb: Unexpected Character in input: ' (ASCII=92) state=1

Asked

Viewed 4,692 times

4

I’m staying at the Locaweb and is making this mistake.

Warning: Unexpected Character in input: ' (ASCII=92) state=1 in /home/Storage/a/B7/B3/reciclaoleovegetal/public_html/public/index.php on line 52

Parse error: syntax error, Unexpected T_STRING in /home/Storage/a/B7/B3/reciclaoleovegetal/public_html/public/index.php on line 52

  • What version of Laravel and what version of PHP is in your Ocaweb?

  • @Guilhermenascimento php is running the 7.1 is the Laravel is in the latest version 5.4

1 answer

8


Messages like:

Warning: Unexpected character in input: '\' (ASCII=92) state=1

And:

Parse error: syntax error, unexpected T_STRING

Indicate two possibilities, either you edited something you shouldn’t and broke the script, or you’re using older version of PHP that doesn’t support Laravel.

By message Unexpected character in input: '\' you must be using PHP 5.2, because namespaces only work after 5.3

But it is important to know that the use of ::class, that this in line 52 of index.php does not work in neither PHP 5.3:

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

To make sure the version create a file called info.php in public_html and add this:

<?php
echo 'Versão Atual do PHP: ' . phpversion();

It will display the details of your PHP version, so you will be sure if it is 7.1, if it is in fact 7.1 then it means that either you damaged index.php or it failed to upload.

If the version is correct and index.php is like this:

<?php

define('LARAVEL_START', microtime(true));

require __DIR__.'/../vendor/autoload.php';

$app = require_once __DIR__.'/../bootstrap/app.php';

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

Then the problem is in the upload, if you are using Filezilla, maybe your FTP is breaking something while trying to climb as ASCII, so that it does not lose data upload as binary, for example in Filezilla go to:

Transfer > Transfer type > and change Auto for Binary

As in the image:

filezilla

Then upload it again.

  • So, the PHP version is 7.1, and I haven’t changed any Script yet, I did the installation by Composer and already appeared this error

  • @Robsonrodrigues see the edition of the answer, if it is in fact 7.1 confirms me that I have another suggestion for you.

  • @Robsonrodrigues for the message Unexpected character in input: '\' for sure you are using PHP 5.2, because in php5.2 there were no namespaces yet.

  • 1

    I could solve it, the problem was in the hosting, whenever I did the installation of the Laravel via Composer, the php version was changed from 7.1 to 5.2, so I had to change the php version again, only discovered thanks to the posts

  • @Robsonrodrigues then mark the answer as correct if you do not know how to read: https://pt.meta.stackoverflow.com/a/1079/3635 - Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.