Program for focal length of a lens | Function to determine the focal length of a lens ; variable to store the distance between the lens and the image ; variable to store the distance between the lens and the object
< ? php function focal_length ( $ image_distance , $ object_distance ) { return 1 / ( ( 1 / $ image_distance ) + ( 1 / $ object_distance ) ) ; } $ image_distance = 2 ; $ object_distance = 50 ; echo " Focal ▁ length ▁ of ▁ a ▁ lens ▁ is ▁ " , focal_length ( $ image_distance , $ object_distance ) , " ▁ units ▁ . " ; ? >