我的客户说他使用我的脚本收到此错误:
Warning: Unexpected character in input: ''' (ASCII=92) state=1 in /path/to//header.php on line 34
Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in/path/to/header.php on line 34
header.php
中的第 34 行只是use 'Main'Class;
现在,我告诉他他必须有PHP >= 5.3.0
,他说他的PHP版本是5.3.24
可能是什么问题?
编辑:前后的行
30. // Define absolute path
31. define("ABSPATH", $abs_path);
32. $_SESSION["abs_path"] = ABSPATH;
33.
34. use 'CNS'main'CNS;
35. $cns = new CNS();
编辑2:
他给我发了这个:
Program Version
Apache: 2.2.24
CentOS: CentOS release 6.4 (Final)
cPanel: 11.36.1 (build 8)
Curl: 7.12.1
MySQL 5.5.30
phpMyAdmin 3.5.5
Python: 2.6.6
Program Version
Perl: 5.8.8
**PHP: 5.3.24**
ionCube Loader: 4.2.2
Zend Optimizer: 3.3.9
Ruby: 1.8.7
Rails: 3.2.8
OpenSSL: 1.0.0-fips
如果您尝试使用命名空间但没有 PHP 5.3,则会发生这种情况。PHP 5.2 及更低版本不支持命名空间,并在看到反斜杠时引发此错误。
--编辑:混淆版本。如果我没记错的话,它是 5.2 及以下
现在,我告诉他他必须有PHP>= 5.3.0,他说他的PHP版本是5.3.24
。可能是什么问题?
他的PHP版本实际上是<5.3.0,不管他是否知道。
请参阅许多 PHP 版本上发生的错误。
如果在上述错误后遇到"意外T_STRING"错误,则需要安装 PHP 5.4+
让他用phpinfo()
创建一个文件。他可能没有PHP版本>= 5.3.0。
<FilesMatch "'.(inc|php|php3|php4|php44|php5|php52|php53|php54|php55|php56|phtml|phps)$">
AddHandler x-httpd-php53 .php
</FilesMatch>
在 .htaccess 中
我遇到了同样的问题,做了一些研究,我设法解决了它。就我而言,我使用 PHP7,我所要做的就是编辑位于 ~/.composer/vendor/laravel/installer/
的文件 laravel,其中 shebang 行#!/usr/bin/env php
我更改为#!/usr/bin/env php7
再次运行工匠后,我让它工作:
-bash-3.2$ laravel
Laravel Installer version 1.3.3
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
help Displays help for a command
list Lists commands
new Create a new Laravel application.
就像其他用户说的那样:命名空间的使用仅适用于高于 5.3.0 的 PHP 版本,因此我的解决方案是能够包括使用命名空间的库的可选使用是检查 PHP 版本并使用 eval(( 函数来避免较低版本的 PHP 触发错误,即使在编译时也是如此。
像这样:
if ( phpversion() > '5.3.0' ){
include_once('/path/to/Library.php');
eval("Library'Foo::bar();");
}
就我而言,我正在使用 Virtualbox 运行 Vagrant,并且 Oracle 在发送文件系统调用中存在已知错误,如果文件位于共享文件夹中,则会导致文件仅部分读取。可能的修复包括添加到nginx配置中
sendfile off;
但这并不总是有帮助的。在我的最新案例中,只需编辑文件(添加注释或空格(,再次保存它,最后重新启动php-fpm就会有所帮助。