标签: syntax-error

PHP 错误行号完全关闭

我不知道我的 PHP 发生了什么。我正在使用我自己开发的一堆类和一个半 MVC 框架(作为实验)。所以 PHP 文件包含了很多类文件。

我的错误消息的 PHP 行号完全关闭,因此无用,使我无法调试。例如,现在我收到一条错误消息,内容为:

`Parse error: syntax error, unexpected ')' in /view.php on line 209
Run Code Online (Sandbox Code Playgroud)

唯一的问题是:在第 209 行附近没有“)”。更糟糕的是,如果我die()在第 200 行左右,它仍然给我一条错误消息,现在被推到第 210 行。很明显,代码行是被考虑在内,但由于某种原因它并没有消亡。

另一件事是,它在此行之前包含一个 header.php 文件。头文件基本上只是输出一些 HTML,在其他页面上工作正常。然而在这个页面上,它甚至不输出标题;它只是死在一个空白页和那个错误信息上。

我能做些什么来使用更可靠的调试吗?如果我能有一个准确的行号,我相信我会很容易找到这个错误。

编辑:我发现了错误。这个问题的重点不是解决意外的 ')' 错误。关键是:为什么行号不准确?实际的错误消息在第 218 行,而不是 209 或 210。

php debugging syntax-error

5
推荐指数
1
解决办法
2365
查看次数

在 jquery 中使用 eval 时,Uncaught SyntaxError: Unexpected token < 是什么错误?

我有一个简单的ajax调用:

function message(){
    $.ajax({
        type: "GET",
        url: "/file/timestamp="+ timestamp,
        async: true,
        cache: false,
        success: function(data){
            var json = eval('('+data+')');
            console.log(json);
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

我Uncaught SyntaxError: Unexpected token <在这一行收到一个错误:var json = eval('('+data+')');

有任何想法吗?

谢谢。

编辑:错误中的更多详细信息:

$.ajax.successajax.js:9
f.Callbacks.njquery.js:2
f.Callbacks.o.fireWithjquery.js:2
wjquery.js:4
f.support.ajax.f.ajaxTransport.send.d
Run Code Online (Sandbox Code Playgroud)

如果有帮助,这里有一些 php

public function fileAction()
{
    $this->getHelper('viewRenderer')->setNoRender();

    $filename = '/test/text.txt';

    $front  = Zend_Controller_Front::getInstance();
    $data   = $front->getRequest()->getParams();

    $lastModif      = !empty($data['timestamp']) ? $data['timestamp'] : 0;
    $currentModif   = filemtime($filename);

    while($currentModif <= $lastModif){
        usleep(10000);
        clearstatcache();
        $currentModif = filemtime($filename);
    }

    $response = array(); …
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery syntax-error

5
推荐指数
1
解决办法
9390
查看次数

为什么某些字符文字导致Java中的语法错误?

在JavaSpecialists通讯最新版中,作者提到了一段代码是在Java中未编译

public class A1 {
  Character aChar = '\u000d';
}
Run Code Online (Sandbox Code Playgroud)

尝试编译它,你会收到一个错误,例如:

A1.java:2: illegal line end in character literal
              Character aChar = '\u000d';
                                ^

为什么等效的c#代码没有出现这样的问题?

public class CharacterFixture
{
  char aChar = '\u000d';
}
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?

编辑:我的初衷是c#编译器如何解析unicode文件正确(如果是这样)以及为什么java仍然应该坚持使用不正确的(如果是这样)解析?编辑:我还想恢复原始问题标题?为什么这么重的编辑,我强烈怀疑它严重改变了我的意图.

c# java unicode syntax-error

5
推荐指数
1
解决办法
302
查看次数

Visual Studio 在 razor 语句中显示语法错误但有效

我在 MVC 3 中有一个项目。它运行良好,每次我构建它时,它都会成功。但是,Visual Studio 坚持在每个 razor 语法的视图中显示编译错误。例如:

当前上下文中不存在名称“模型” D:\ ... Detail.cshtml

那行很简单:

@model Namespace.DetailViewModel
Run Code Online (Sandbox Code Playgroud)

我已经试过了:

  • 清洗液
  • 清洁解决方案和删除bin和obj文件夹。
  • 关闭 VS 并重新打开它(即使在中间重新启动)。

注意:我使用的是 Visual Studio 2012。

asp.net-mvc syntax-error razor asp.net-mvc-3 visual-studio-2012

5
推荐指数
1
解决办法
5782
查看次数

如何使用 Python subprocess.Popen 控制 gdb?

所以我正在编写(或至少尝试编写)一个程序来比较在 python 中运行的两个 gdb 的输出。这是我到目前为止:

from subprocess import *
import subprocess

file = raw_input('enter program name (with a ./ if in local directory): ')

p1 = Popen(['gdb', file], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p2 = Popen(['gdb', file], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

p1.communicate(input='break main')
p2.communicate(input='break main')

args1 = raw_input('args for running program (from file) (ie r < input.txt): ')
args2 = raw_input('args for running program (from file) (for program 2...): ')

p1.communicate(input=args1)
p2.communicate(input=args2)

while True:
    p1out = p1.communicate(input='continue')[0]
    p2out = p2.communicate(input='continue')[0]

    if p1out != …
Run Code Online (Sandbox Code Playgroud)

python debugging gdb syntax-error

5
推荐指数
1
解决办法
3691
查看次数

二进制/十六进制浮点输入

为什么基数10只允许小数点?为什么以下引发语法错误?

0b1011101.1101
Run Code Online (Sandbox Code Playgroud)

我打字的号码有些含糊不清吗?看起来没有可能的数字,字符串可以表示除了93.8125

同样的问题也适用于其他基地:

0x5d.d
Run Code Online (Sandbox Code Playgroud)

我可以用一个相当简单的函数来编程:

def base_float(number_string, base):
    n = number_string.split('.')
    number = int(n[0], base)
    if len(n) > 1 and len(n[1]):
        frac_part = float(int(n[1], base)) / base**len(n[1])
        if number < 0:
            frac_part = -frac_part
        number += frac_part
    return number
Run Code Online (Sandbox Code Playgroud)

它给了我预期的代表性:

>>> base_float('0b1011101.1101', 2)
93.8125
Run Code Online (Sandbox Code Playgroud)

int接受任意基数,但没有小数点,并float接受小数点但没有任意基数.为什么?

python floating-point numbers syntax-error python-2.7

5
推荐指数
1
解决办法
382
查看次数

将值推送到数组AngularJS

我试图用.push();将数据值推送到AngularJS中的数组,但我总是收到此错误消息:

Error: $scope.test.push is not a function
Run Code Online (Sandbox Code Playgroud)

这是我的HTML:

<div ng-controller="Test">
<div class="container">
<div class="col-sm-9 col-sm-offset-2">

    <div class="page-header"><h1>Testar</h1></div>
    <table class="table table-striped table-condensed">
    <thead>
        <tr>
            <th>Sträcka</th>
            <th>Tid</th>
         </tr>
    </thead>
        <tr ng-repeat="info in test"><td>{{info.stracka}}</td><td>{{info.tid}}</td></tr>
    </table>

    <form name="userForm" ng-submit="submitForm(userForm.$valid)" novalidate> <!-- novalidate prevents HTML5 validation since we will be validating ourselves -->
        <div class="form-group" ng-class="{'has-error' : userForm.stracka.$invalid && !userForm.stracka.$pristine, 'has-success' : userForm.stracka.$valid }">
            <label>Sträcka(m):</label>
            <input type="text" name="stracka" class="form-control" ng-model="form.stracka" required>
            <p ng-show="userForm.stracka.$invalid && !userForm.stracka.$pristine" class="help-block">Fel sträcka</p>
        </div>

        <div class="form-group" ng-class="{'has-error' : userForm.tid.$invalid && !userForm.tid.$pristine, …
Run Code Online (Sandbox Code Playgroud)

javascript syntax-error angularjs

5
推荐指数
1
解决办法
4万
查看次数

元素"xsd:schema"的前缀"xsd"未绑定

我收到了这个WSDL,我遇到了XSD的问题.

我似乎无法在我的XSD文件中找到问题.

什么没约束?我怎么解决这个问题?

error: The prefix "xsd" for element "xsd:schema" is not bound.
Run Code Online (Sandbox Code Playgroud)

这是XSD文件的一部分:

 <xsd:schema targetNamespace="http://www.informatica.com/wsdl/"
             elementFormDefault="qualified"
             attributeFormDefault="unqualified"
             xmlns="http://www.informatica.com/wsdl/"
             xmlns:infatype="http://www.informatica.com/types/">
      <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/http/"/>
         <xsd:element name="SHA003Bis_GetArticleDataResponse"
                      type="SHA003Bis_GetArticleDataResponseType"/>
         <xsd:element name="SHA003Bis_GetArticleDataRequest"
                      type="SHA003Bis_GetArticleDataRequestType"/>
         <xsd:complexType name="SHA003Bis_GetArticleDataRequestType">
            <xsd:sequence>
               <xsd:element name="SHA003Bis_GetArticleDataRequestElement">
                  <xsd:complexType>
                     <xsd:sequence>
                        <xsd:element name="Company" minOccurs="0" maxOccurs="1">
                           <xsd:simpleType>
                              <xsd:restriction base="xsd:integer"/>
                           </xsd:simpleType>
                        </xsd:element>
Run Code Online (Sandbox Code Playgroud)

这是WSDL的一部分:

<wsdl:definitions targetNamespace="http://www.informatica.com/" 
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
                  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
                  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
                  xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
                  xmlns:n="http://www.informatica.com/wsdl/" 
                  xmlns:infa="http://www.informatica.com/" 
                  xmlns="http://schemas.xmlsoap.org/wsdl/">
   <wsdl:types>
      <xsd:schema targetNamespace="http://www.informatica.com/wsdl/"
                  elementFormDefault="qualified"
                  attributeFormDefault="unqualified"
                  xmlns="http://www.informatica.com/wsdl/"
                  xmlns:infatype="http://www.informatica.com/types/">
         <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/http/"/>
         <xsd:element name="SHA003Bis_GetArticleDataResponse"
                      type="SHA003Bis_GetArticleDataResponseType"/>
         <xsd:element name="SHA003Bis_GetArticleDataRequest"
                      type="SHA003Bis_GetArticleDataRequestType"/>
         <xsd:complexType name="SHA003Bis_GetArticleDataRequestType">
            <xsd:sequence>
               <xsd:element name="SHA003Bis_GetArticleDataRequestElement">
                  <xsd:complexType>
                     <xsd:sequence>
                        <xsd:element name="Company" …
Run Code Online (Sandbox Code Playgroud)

xml xsd wsdl syntax-error xml-error

5
推荐指数
1
解决办法
1万
查看次数

IF语法错误

我在遵循MySQL指南的IF语法时遇到语法错误.

我的查询是:

if 0=0 then select 'hello world'; end if;
Run Code Online (Sandbox Code Playgroud)

从逻辑上讲,这应该选择'hello world',但我得到了

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'if (0=0) then select 'hello world'' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use …
Run Code Online (Sandbox Code Playgroud)

mysql sql syntax if-statement syntax-error

5
推荐指数
1
解决办法
1445
查看次数

为什么没有检测到这个Ruby语法错误?

以下代码的语法无效:

# bad_code.rb
def foo
  next
end

$ ruby bad_code.rb 
bad_code.rb:2: Invalid next
bad_code.rb: compile error (SyntaxError)
Run Code Online (Sandbox Code Playgroud)

但是,运行时ruby -c bad_code.rb没有检测到任何问题:

$ ruby -c bad_code.rb 
Syntax OK
Run Code Online (Sandbox Code Playgroud)

但是ruby -c应该用于检查语法:

-c仅检查语法

为什么不检测到这个错误?

rubocop bad_code.rb 也没有发现这个:

$ rubocop bad_code.rb 
Inspecting 1 file
.

1 file inspected, no offenses detected
Run Code Online (Sandbox Code Playgroud)

我在Ruby 2.1.10上运行了这个.

ruby syntax-error rubocop

5
推荐指数
1
解决办法
138
查看次数