syntax-error

Java variable scope in if statement [duplicate]

自作多情 提交于 2019-11-27 04:24:45
问题 This question already has answers here : Declaring a useless local variable (2 answers) A single-line loop with a mandatory pair of braces in Java (3 answers) Closed 4 years ago . I received a compilation error for the following code: if(true) int a = 10; else int b = 20; If I change it to the following code, then there is no compilation error: if(true) { int a = 10; } else { int b = 20; } Why is the first syntax wrong, and from what language standard? 回答1: The Java specification says that an

Unexpected token < in first line of HTML

♀尐吖头ヾ 提交于 2019-11-27 03:01:33
问题 I have an HTML file : <!DOCTYPE HTML> <html lang="en-US" ng-app="Todo"> <head> <meta charset="UTF-8"> <title>DemoAPI</title> <meta name="viewport"> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script> <link rel="stylesheet" href="./Client/css

Lisp, instructions not working in defun [duplicate]

余生颓废 提交于 2019-11-27 02:17:49
This question already has an answer here: Common lisp error: “should be lambda expression” 4 answers I'm trying to make a function that changes infix input to prefix eg : (x + 1) as input outputted as (+ x 1) . So here is my code for the moment : (setq x '(Y + 1)) (if (listp x ) (list (second x) (first x) (first (last x))) x) so it returns (+ Y 1) if I input a list and the user input if it's not a list. However, the problem is that I can't get this code working in a function : (defun prefixToInfix (x)( (if (listp x ) (list (second x) (first x) (first (last x))) x) ) ) the function is indeed

calling function inside preg_replace thats inside a function

非 Y 不嫁゛ 提交于 2019-11-27 02:08:51
I have some code with the a structure similar to this function bbcode($Text) { //$Text = preg_replace("/\[video\](.+?)\[\/video\]/",embed_video($1), $Text); return $Text;} function embed_video($url){ if (preg_match("/http:\/\/www.youtube.com\/watch\?v=([0-9a-zA-Z-_]*)(.*)/i", $url, $matches)) { return '<object width="425" height="350">'. '<param name="movie" value="http://www.youtube.com/v/'.$matches[1].'" />'. '<param name="wmode" value="transparent" />'. '<embed src="http://www.youtube.com/v/'.$matches[1].'&autoplay="0" type="application/x-shockwave-flash" wmode="transparent" width="425"

Parse error: syntax error, unexpected '[', expecting ')' [duplicate]

孤人 提交于 2019-11-27 02:05:54
This question already has an answer here: PHP syntax for dereferencing function result 22 answers I have this linecode $media = $dc->thumbnail->attributes()['url']; runs fine on my local (WAMP) php 5.4.3 but when i host it on my server cpanel then it gives this error Parse error: syntax error, unexpected '[', expecting ')' the php version on my server is 5.2.17 i dnt see any problem with it, please help You need to be running PHP 5.4+ to use shorthand arrays You can't have a php 5.4.3 and a 5.2.17 with a single WAMP installation, but from your error message, i think you are using the older one

Parse error: syntax error, unexpected '(', expecting ',' or ';' in

浪尽此生 提交于 2019-11-27 02:04:10
I am recieveing the following parse error: Parse error: syntax error, unexpected '(', expecting ',' or ';' in H:\Programs\USBWebserver v8.5\8.5\root\oopforum\func\register.class.php on line 7 which relates to the following line of code in my class: private $random_name = rand(1000,9999).rand(1000,9999).rand(1000,9999).rand(1000,9999); I can not see why this line of code would cause a parse error? Here is some surrounding code: class register{ public $post_data = array(); private $dbh; private $allowed_type = array('image/jpeg','image/png','image/gif'); private $random_name = rand(1000,9999)

JavaScript: {}==false is a SyntaxError?

≯℡__Kan透↙ 提交于 2019-11-27 01:37:12
问题 In Firefox 3.5, I type this in the Firebug console : false=={} // => evals to false {}==false // syntax error What is the explanation for this ? 回答1: { at the start of a statement signals a ‘statement block’ (see ECMA-262-3 section 12.1), which contains a list of statements. } immediately ends the statement block with no statements in it. That's fine. But now the parser is looking for the next statement: ==false Huh? That's not a statement; syntax error. What are statement blocks for? Well,

Python 3.2 Lambda Syntax Error [duplicate]

萝らか妹 提交于 2019-11-27 01:19:39
问题 This question already has an answer here: Nested arguments not compiling 1 answer def sort_dictionary( wordDict ): sortedList = [] for entry in sorted(wordDict.iteritems(), key = lambda (k, v): (-v, k) ): sortedList.append( entry ) return sortedList The function would be receiving a dictionary containing information such as: { 'this': 1, 'is': 1, 'a': 1, 'large': 2, 'sentence': 1 } I would like to have it generate a list of lists, with the elements ordered first by the dictionary's values

How do I fix this missing semicolon syntax error in Javascript?

限于喜欢 提交于 2019-11-27 00:48:01
问题 A friend wrote some code for me, and there was one file with a weird syntax error in it. After a bit of hunting, I narrowed it down to this section of code, which should reproduce the error: var say = functіon(message) { alert(message); return message; }; say(say("Goodbye!")); When I run this, I see an error in the Internet Explorer console that says SCRIPT1004: Expected ';' . I don't see a semicolon missing anywhere, and I can't imagine where it wants me to put one. Where does it expect a

PHP Notice: Undefined offset: 1 with array when reading data

断了今生、忘了曾经 提交于 2019-11-27 00:16:14
问题 I am getting this PHP error: PHP Notice: Undefined offset: 1 Here is the PHP code that throws it: $file_handle = fopen($path."/Summary/data.txt","r"); //open text file $data = array(); // create new array map while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); // read in each line $parts = array_map('trim', explode(':', $line_of_text, 2)); // separates line_of_text by ':' trim strings for extra space $data[$parts[0]] = $parts[1]; // map the resulting parts into array //