duanqiao9541 2015-01-30 04:30
浏览 36

为什么在我的html文档中尝试使用php命名空间时会出现解析错误?

I am using a php namespace on my html page. I'm using Windows 8. My code works perfict on my machine which is running WAMPSERVER 2.5. I uploaded the files to my web site and got a parse error that says:

 Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /home/content/15/8677915/html/myDirectory/fileName.html on line 73

Line 73 has this line of code: use myNamespace\UploadFile;

Here's the partial code that causes the error:

 <?php 
 use myNamespace\UploadFile;   <--------line 73

 require_once 'uploads/src/myNamespace/UploadFile.php';
 if (!isset($_SESSION['maxfiles'])) {
 $_SESSION['maxfiles'] = ini_get('max_file_uploads');
 $_SESSION['postmax'] = UploadFile::convertToBytes(ini_get('post_max_size'));
 $_SESSION['displaymax'] =      UploadFile::convertFromBytes($_SESSION['postmax']);

 }
 ....more code....
 ?>

I tried using escape like this: use myNamespace\UploadFile; but still the same error. So I figured it may have something to do with UploadFile.php so I removed the line: use myNamespace\UploadFile; Then I got a another parse error. This time it came from the UploadFile.php. Here's what the error looks like:

 Parse error:  syntax error, unexpected T_STRING in     /home/content/15/8677915/html/dc-esports/uploads/src/myDirectory/UploadFile.php on line 2

Here's the code that is at the very top of the UploadFile.php file:

 <?php
 namespace westcoastchill;  <--------- line 2

 class UploadFile
 {
  protected $destination;
  protected $messages = array();
  protected $maxSize= 51200;
  .....more code here
 ?>

What is the parsing error here?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog