file handling with ksh scripting

how can i write content of a variable to a file?

how can i read standard output into a variable?

# how can i write content of a variable to a file?
echo "$myvariable" > myfile           # start
echo "$myvaririable" >> myfile        # append

#how can i read standard output into a variable?
# output from ls command stdout into variable
myvar=$( ls )