Questions tagged as 'sintaxe'

4
answers

Why an if can be redundant?

Using a method that returns a boolean the system would determine whether a number is positive or negative. So I did it this way: public boolean isPositive(float num) { boolean positive; if (num >= 0) { positive = tru...
asked by 19.04.2016 / 21:02
1
answer

What is it and how does it repeat in C #?

for (int i = 0; i < palavra.Length; i++) What does each word mean? And how does each part of this code work?     
asked by 15.09.2017 / 13:04
2
answers

What happens if I do not specify {}?

I have this code that works normally: if($time <= time()) { if($time != 0) $Server->wsSend(1, 'perfect world'); foreach ( $Server->wsClients as $id => $client ) $time = time() + $adminMess...
asked by 15.03.2015 / 16:52
2
answers

Why can not I declare a variable with a number in front?

I'm curious to know why not being able to create variables with a number up front. I did some tests in JavaScript, ActionScript and C #. var 4teste:String = "teste"; //ActionScript, erro! var 4teste = "teste"; //Javascript, erro! String 4teste...
asked by 29.07.2015 / 15:43
4
answers

Interpretation of repetition loop

I'm having trouble understanding the following code that is presented as a book exercise. $a = true; $b = -2; $c = 7; for ( ; $b < $c || $a; $b++){ if ($c + $b * 2 > 20) $a = false; echo $b." "; } The result is: -...
asked by 10.10.2018 / 00:58
3
answers

What happens in the expression "$ a +++ (++ $ a)"?

I was joking with PHP to see if I could find something that sounded strange with the syntax, inspiring me in the question What happens in 1 ... 1 in PHP? . I ended up with the code: $a = 0; $a+++(++$a) The above "joke" returned 2...
asked by 05.08.2017 / 21:14
1
answer

Array in PHP using () or []?

I always use the parentheses to define an array in PHP, such as: $array = array('a','b','c'); But every now and then I see some code here using brackets, like: $array = ['a', 'b', 'c']; However, if I use brackets, I get the error:  ...
asked by 01.05.2018 / 00:06
1
answer

SQL query within another query

I'm performing an update on the database, but it needs to get the last ID that was written. Where does where I put another command in? In this way: $sql = mysqli_query($conexao, "UPDATE cadastro set...
asked by 01.10.2015 / 19:56
2
answers

Why use only return, without returning any data?

Studying the code of a framework I came across the following code snippet: if (file_exists('lib/util/' . $className . '.php')) { include 'lib/util/' . $className . '.php'; return; } What is the purpose of using return wit...
asked by 28.05.2016 / 15:42
1
answer

What are C-digraphs?

Based on the trigraphs question, what are digraphs? Why were they created? What are the sequences? Do the current compilers still allow you to use them?
asked by 18.12.2015 / 21:43