How can I create global code variables? I'm wondering if there's any equivalent to the Yii "params" array I can set on Twig code template level for re-use throughout all my templates using Twig syntax?
Besides saving the variable in a field (e.g. global set) you could also add a "Environment Variable" to
your general.php file:

'myGlobalVariable' =&gt; 'I am available in all environments'

but you can only access it from Twig, it's not possible to update it:

{{ craft.config.myGlobalVariable }}

If you do need to update from  your Twig templates, you should make a custom plugin / add to your Business Logic plugin.
There's various options to make a variable available in your Twig templates:


add a "Template Variable" to the {{ craft }} global variable


or with a Twig Extention:


add a new Global Variable using getGlobals()
add a Twig function with new Twig_SimpleFunction()


With a plugin you have these options to save your value (and update with a custom Twig function):


in a Record, update with $record-&gt;save()
directly in the plugin settings, update with craft()-&gt;plugins-&gt;savePluginSettings() (→ read more on SE)
with a config.php file in the plugin folder, not possible to update with Twig (→ read more on SE)
hard code it into the plugin PHP ;)