I was trying to print the value of a variable from a function, but it is showing undefined variable value. Please help me and tell me how to solve this problem; I'm pretty new
to PHP coding. I tried the function as public, but it shows some other error.
<?php
    if(isset($_POST['btn_submit']))
    {
        $num1 = $_POST['cards1'];
        $num2 = $_POST['cards2'];
        $num1=substr($num1,0,(strlen($num1)-1));
        $num2=substr($num2,0,(strlen($num2)-1));
    }
    function get_value() {
        switch ($num2) {
            case 'A' :
                $value = 11;
                break;
            case 'J':
            case 'Q':
            case 'K':
                $value = 10;
                break;
            default:
                $value = $num2;
                break;
        }
            //return $value;
    }   
    echo '<script type="text/javascript">alert("Out Put is'.$value.' ");</script>';
        //$total_value =  $num1+$num2;      
  ?>
 
     
    