<? function mi_funcion(){ $variable=2; return $variable; } // en otro lugar de tu página puedes poner echo mi_funcion(); ?>