Sharing var across functions using global var

Posted under » PHP » Python on 26 May 2023

To share var across functions, you need to declare the var as global. Example in PHP

function replcae() // replaces stuff
global $kontent; 
$kontent = str_replace(" "," ",$kontent);

function k0ntent()
global $kontent, $folio;
$kontent = implode('', file($folio.".html"));

In Python or rather Django, it may look like this, where slatus is global

def showstatus(request):
    global slatus
    current_user_id =
    checkobj = Progress.objects.filter(user_id=current_user_id)
    if checkobj.exists():
        status = atus.status
        if "b-" in status :
            slatus = 'Diagnostic'
       return slatus

def showqtogo(request):
    if slatus=='Diagnostic':
        slage = 1
    checkobj = Users.objects.filter(stage=slage)
    if checkobj.exists():
            q2go = str(checkobj.count())
            return q2go

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS data