Unexpected Character in Input: '\' (Ascii=92) State=1

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

You cannot accomplish this with a simple preg_replace, as array de-referencing is not done with /e modifier. Instead you can use preg_replace_callback function:

$tag_value = preg_replace_callback("/\{(.*?)\}/", function($m) use($values){
return $values[$m[1]];
}, $tag_value);

This definitely works in php 5.3, however in 5.2 you may need to define the callback function explicitly:

function replace($m) {
global $values;
return $values[$m[1]];
}
$tag_value = preg_replace_callback("/\{(.*?)\}/", "replace", $tag_value);

EDIT: The error you are seeing is happening because with your original code, your substitution is being treated literally as $values[\1] (after unescaping the backslash - in this string, \1 is not the right stuff to put inside the brackets.

Unexpected character in input: '\' (ASCII=92) state=1 in a Silex Application

According to the official documentation, Silex requires PHP 5.3 to provide namespace support.

Try to migrate your server to PHP 5.3 in order to get rid of this error.

Silex is a PHP microframework for PHP 5.3.

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

Quoting from the Wiki here on StackOverflow

PHP 6

On July, 30th, 2014 a majority of the PHP steering group decided to skip version 6 to avoid confusion with an earlier but abandoned PHP 6 project (dubbed the Unicode release). While there never was any official release of PHP 6, many books and articles had been published already.

PHP 6 Does not exist, and never will officially exist. It was completely deleted from the version control repository.

The fact that AppServ still provides access to AppServ 2.6.0 show a complete lack of responsibility on their part.

The latest official version of PHP is 5.6.13, use that official release. The next major release (around November 2015) will be PHP 7.... there will be no PHP 6

Unexpected character in input: '\'

There's probably cli php version 5.4 available, ask Bluehost for the full path and use it.



Related Topics



Leave a reply



Submit