why don't you start with a smallest function? Then learn how to use a variable inside a function, and how could you return this variable. http://hu2.php.net/manual/en/functions.returning-values.php
This function never do anything, just return 457
function Get_Max_Exp($L){
$end=0;
if ($exp == 0){
return 457;
$end =1;
}
This code is doing this :
lets add a value to $end, which is 0
if $exp is equal with 0, then return 457! Hey! $exp is always equal with 0, so i always return 457. As i see, in the next line i shoud create another value for $end, but i've returned so i can't do that!
You code is full of undefined variables, if you want to know which are, lets use error reporting:
error_reporting(E_ALL);