Question: I always try to make use of the var keyword when inside functions using CF, but one probably stupid question I have is, how often do you have to use it ?

Example : 

```
<cfset var local = ""> <!-- set at the top of the function -->

<!-- then later in the function -->
<cfset var local.firstname = "steve">
<cfset var local.lastname = "smith">
<cfset var local.email = "email@email.com">

```

is it a case of every time you write a variable you have to set the keyword, or just the first instance of it when used within a function ?

Or is it just the same as

```
<cfset var local = ""> <!-- set at the top of the function -->

<!-- then later in the function -->
<cfset local.firstname = "steve">
<cfset local.lastname = "smith">
<cfset local.email = "email@email.com">

```

Answer: 
You do not need to use the 'var' keyword for variables that are in the 'local' scope. Since 'local' is a structure all its members are part of the same scope.

Basically the 'local' struct is just a container to hold all variables that must be in the function's local scope.

**UPDATE:**
AS of CF9 `local` is an explicit scope that you use to hold your function scoped variables, without declaring it. Usually I type it uppercase but that's a matter of taste.

```
<cfset LOCAL.firstname = "steve">
<cfset LOCAL.lastname = "smith">
<cfset LOCAL.email = "email@email.com">

```

In Coldfusion 8 and before you would typically define a `local` struct at the top of your function:

```
<cfset var LOCAL = structNew() />

```

However you could choose any other name for that struct.
If you are not using the local scope, you only have to use the keyword `var` once per variable.

I was introduced to User Defined Functions with version 7.1. I'm not sure about other versions, but in that one, you had to `var` all your variables right after the `cfargument` tags, before any other commands were executed. In other words, this was ok.

```
<cffunction etc>
<cfargument name = "arg1">
<cfset var x = 0>
<cfquery>
sql goes here
</cfquery>
<cfset x = 3>

```

but this would throw an error:

```
<cffunction etc>
<cfargument name = "arg1">

<cfquery>
sql goes here
</cfquery>
<cfset var x = 3>

```