is_single()
is a function returning a boolean
value. You could simply use it for your conditional check rather than passing the global variable.
Other than that, your first line of code should be setting $my_global_var
with a single equal sign, i.e.: $my_global_var = true;
.