Most voted "variables" questions
A variable is a named data storage location in memory. Using variables , a computer program can store text numbers, binary data, or a combination of any of these data types. They can be transferred in code, to other functions and even other applications.
Learn more…645 questions
Sort by count of
-
2
votes3
answers956
viewsVariable array assignment
There is a correct way to do this highlighted code snippet? $numeros = range(0, 9); shuffle($numeros); $id = array_slice($numeros, 1, 9); $mult =…
-
2
votes1
answer400
viewsHow to Find previous PHP variable value
I have a variable that has the value of rice, soon after receiving the value of rice, she gets the value ugliness. How do I call the past value of the function? Follow example below: $arroz =…
-
2
votes1
answer3116
viewsAdd multiple select Count results to MYSQL
I’m wanting to add up all the clients I have on all my bases, so for that I’m doing the following query: SET @total = 0; USE BASE x1; SELECT @total:= @total +COUNT(1) FROM clientes; USE BASE x2;…
-
2
votes2
answers2981
views"Undefined variable" error
I’m trying to run this code but it’s not working. $sql = "SELECT * FROM cliente WHERE id = $id "; $limite = mysql_query("$sql"); while ($sql = mysql_fetch_array($limite)){ $nome = $sql["nome"];…
-
2
votes2
answers198
viewsHow can I do a validation to check if a variable is empty and is a string in php
I want to do a denial check and then else the fix. How can I? Take the example! <?php $a = ''; if(!$a && !is_string($a)): echo 'False'; else: echo 'True'; endif;…
-
2
votes1
answer930
viewsHow to create variable dynamically?
I would like to create a variable for each iteration of a for. Example: for(u=0;u<tamanho;u++) { int variavel[u] = "valor" } It is possible? UPDATE This is the real code. SearchConstraint c1 =…
-
2
votes2
answers155
viewsHow to turn strotime output into a variable
I’m trying to use this script, which returns every Monday between two periods: $beginday = isset($_POST["Tinsem3"]) ? $_POST["Tinsem3"] : false; $lastday = isset($_POST["Tdesl"]) ? $_POST["Tdesl"] :…
-
2
votes1
answer44
viewsCalling a variable from other variables in LESS
How can I call a variable from other variables as in other languages in Less? PHP: $name = 'stack'; $level = '900'; $nameVariable = $name . $level; ${$nameVariable}; // chama variável: $stack900…
-
2
votes1
answer624
views -
2
votes1
answer2796
viewsGlobal variable used in multiple functions
I have this code: donos=[] def calcula_media(): lista_dicionario= [1,2,3] donos.extend(lista_dicionario) def funcao2(): print donos How can I use the global variable in the 2nd function using what I…
-
2
votes1
answer246
viewsProblem to assign more than one value to variable
#include <stdio.h> int main(){ int d; int e; int peca1; printf("digite um lado da peca: "); scanf("%i", &d); printf("digite outro lado da peca: "); scanf("%i", &e); peca1 = d , e…
-
2
votes1
answer53
viewsVariable gets another value even without assigning values to it
I call a Jframe passing as parameter my variable and there I assign it in another variable I declared in order to be able to do the necessary operations. But when I close the Jframe 2 my variable of…
-
2
votes1
answer142
viewsAccessing variables dynamically in C language
I understand that it is possible to access variables dynamically in Javasscript, but to do this in C, I can’t find anywhere. Follow the code in Javascript: var n1,n2,n3,n4,n5; n1 = n2 = n3 = n4 = n5…
-
2
votes1
answer296
viewsVariable as Java Method Argument
Do you pass a variable as an argument of a method not its value, but the instance itself, every change made in the argument applies the variable? Just like it works in Javascript?
-
2
votes1
answer99
viewsUnanswered PHP in fetch command
I am studying with a book use the head and the following I practically copied and pasted the sample code just changing the names of the variables and I am not having the return with my code, in fact…
-
2
votes0
answers99
viewswxmaxima. Defining a function of three variables
I’m trying to do some symbolic/algebraic calculations in wxmaxima. But I’m having syntax problems. Question. Let 'n' and’m' be previously stipulated integers. What is the syntax/'command line', as…
-
2
votes1
answer8387
viewsWhen to use Dim and when to use Set?
What are the differences between the Dim and the Set? When to use each? Context 1 Dim minhaString as String minhaString = "Olá!" Context 2 Set minhaString = "Olá!"…
-
2
votes2
answers1174
viewsFormat result of integer division
I have the following code in JAVA: private int metros = 1500, minutos = 60; System.out.println("Distância em km = "+(metros/1000)); System.out.println("Tempo em horas = "+(minutoa/60)); However what…
-
2
votes1
answer504
viewsinsert bash commands into expect
Good evening guys, I have an activity to do that I needed to use Expect to remove user interaction in an SMTP communication. Only that in the body of the email I need to add the current date and the…
-
2
votes1
answer932
viewsHow to set variable within match method (String)
What I want is to include the variable within the (/.../) and not its value. Code: var str = 'Seu texto aqui!'; if (str.match(/texto/)) { alert('Palavra encontrada.'); } Instead of setting manually,…
-
2
votes1
answer1466
viewsHow to store the return value of a function in a local variable in C?
I created a function that returned a certain value when using this function in the function main of the program, how can I store its return, and for example, display this return in a printf in main?…
-
2
votes1
answer53
viewsIn terms of performance, what is the best way to declare a variable that will be used in multiple Actions/Methods in a class?
Which mode is best performatically speaking? Which way you recommend and why? //Modo 1 MeuManager mm = new MeuManager(); JsonResponse MetodoDOIS(string urlImagem) { var abc = mm.Lista(); }…
-
2
votes2
answers429
viewsCreate dynamic variables in Javascript
When I’m in PHP and has dynamic variables, e.g.: nomeVariavel1,nomeVariavel2, nomeVariavel3, I use it as follows to place on the bench: $nomeVariavel = ${"nomeVarivavel".$contador} How can I do…
-
2
votes1
answer865
viewsPython to C++ conversion
I work on my course with C++, and wanted to use a Python class variable access feature. See an example: class Telefone: nums = {} def __init__(self, numero): self.num = numero Telefone.nums[numero]…
-
2
votes1
answer51
viewsError condition in C
When I moved in Python I remember I had how to make one if if any assignment or operation returned error. Type like this int v[]={1,2}; int v1; if((v1=v)==ERRO) //faça isso; There’s something like…
-
2
votes2
answers4786
viewshow do I remove some numbers after the comma in PHP
How do I remove some numbers after the comma in PHP? ex: 25.523832732732... Then I want you to stay only 25.52
-
2
votes1
answer179
viewsFinal local variable in Inner class in Java 8
There was a modification between Java 7 and 8 versions. Where in Java 7 for a local variable to be used within a inner class should be declared final. Now compiling with Java 8, this local variable…
-
2
votes1
answer13343
viewsANDROID_HOME Linux Environment Variable
I am having problem with the environment variable ANDROID_HOME, whenever I try to run the command to run an app in the emulator (or mobile connected), this error message appears Error: Failed to…
-
2
votes2
answers71
views -
2
votes2
answers44
viewsWhich way to change variables is more optimized?
I made two ways to change the value a and b, but which is more optimized, taking this example to other languages like desktop or web. No use auxiliary variable: $a = 10; $b = 5; $a = $b+$a; $b =…
-
2
votes1
answer34
viewsTaking month and year
I have a variable containing it an expression that corresponds to a directory of folders. I want the year and the month before: "c: " + SUBSTRING( (dt_str, 50, 1252)GETDATE(), 1, 4 ) + " " +…
-
2
votes1
answer896
viewsIdentify the type of variable received in a generic function
I have a function in Delphi that receives a kind of generic data, I would like to know what kind of data received, like this: function MinhaFuncao<T>(): T I need to know what kind is in…
-
2
votes2
answers52
viewsSearch only form fields with value other than 0 and put in PHP variable
I have a quote form with 70 products in which the user chooses the amount of products he wants from each one. All are named with id P1, P2...P70 and are number type inputs. <form…
-
2
votes2
answers910
viewsHow to call a variable from others?
My intention is that the code goes through 9 Textbox checking if they are filled with names or empty. For each Textbox filled would be added 1 in a counting variable and would be allocated the text…
-
2
votes2
answers1583
viewsPython - Assign the value of an entry to a variable
I tried to use the command mensagem = str(entry.get()) but it doesn’t work, I tried to use the entry = Entry(root, textvariable='mensagem') but also does not work, see the whole code basically want…
-
2
votes0
answers40
viewsUnsigned variable vs null variable
I have the following codes: String str = null; and String str; If I use one if to check if the variables are null, if will be "called" in both cases. But is there any difference between the two…
-
2
votes1
answer41
viewsSet variables to call a function
I’m trying to include variables to call a function, but I’m not getting it function Geral() { xmlHttp=GetXmlHttpObject(); var url="pagina.asp?a=1"; xmlHttp.onreadystatechange=stateChanged;…
-
2
votes1
answer62
viewsWhat is the default visibility of a variable in Typescript, what is the importance of var when declaring variables?
When declaring a variable, when we omit the visibility parameter (public, private and protected) the variable is created by default in which visibility? export class AddEditTaskPage { idade: number;…
-
2
votes1
answer46
viewsHow to create records in the MYSQL table according to the value of the $nregistros PHP variable
I have a $nregistros variable that defines the value of records to be inserted in the table "Formularios". If $nregistros is equal to 4 for example, it should insert 4 rows as follows: formularios…
-
2
votes1
answer1207
viewsHow to concatenate variable names in Java
I’m having a question. I’m wanting to generate a total of variables, from a for, to not have to write all of them, but I’m not able to concatenate the names of variables. I’m trying this way:…
-
2
votes1
answer1151
viewsWhat is English variable in English?
I’m doing a job on Prolog and when trying to make a query it says there are "Singleton variables". For example, a part of the code: s([Policia_X, Policia_Y, Ladrao_X, Ladrao_Y]) :-…
-
2
votes1
answer321
views -
2
votes2
answers130
viewsLocal variable declaration in a PYTHON function
def fib(n): a, b = 0, 1 while a < n: print(a, end=' ') a, b = b, a+b print() result-> 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 But if I declare the variables a and b in different…
python python-3.x function variables variable-declarationasked 6 years, 3 months ago Rafael Eduh 51 -
2
votes1
answer96
viewsScope of PHP variable
So, I’ve been banging my head for a while now with a basic question of scope, but I couldn’t figure out why. In the function below, I am trying to access a position of the object that is running at…
-
2
votes1
answer105
viewsError creating variable inside IF
I was creating a script that always worked with me, however, I made a small change that almost blew my mind because I didn’t understand what happened and I didn’t find anything on the subject. Is…
-
2
votes1
answer64
viewsDifference of use of immutable object in method argument or outside it
If I have the following String of which it was created: String s1 = "Primeira String"; When using the method: s1.toUpperCase(); nothing happens because an instance has been created and has not been…
-
2
votes3
answers3588
viewsHow to store more than one value in an "SQL variable"?
I work with a system that has a very limited report. The reports are basically restricted to one sql query. I need to present in a report a query that, in my query, is being informed by the user a…
-
2
votes2
answers272
viewsFilter information for the current day
I have the following variable in my View: Auth::user() ->LogsSearch() ->where('base', $linha->sigla) ->where('created_at', date('Y-m-d')) ->count() and I want to filter the results of…
-
2
votes1
answer171
viewsList is not being passed as method parameter
I need to implement the method RoutesBetween to trace the route between a point and another (in this case, point To and And). Test method: public void TestRoutesBetweenTwoPoints() { var links = new…
-
2
votes3
answers1276
viewsA: Creating a new variable using if and Else
I’m with a base of 9 million lines. I’m trying to make a new variable called base$trs_localidade using the variable base$iso_pais being: base$iso_pais<- c( '076', '840', '076','442' , '052' ,…