text: Area of a n | Function to find the area of a regular polygon ; Side and side length cannot be negative ; Area degree converted to radians ; Driver code
code: < ? php function polyarea ( $ n , $ a ) { if ( $ a < 0 && $ n < 0 ) return -1 ; $ A = ( $ a * $ a * $ n ) / ( 4 * tan ( ( 180 / $ n ) * 3.14159 / 180 ) ) ; return $ A ; } $ a = 9 ; $ n = 6 ; echo round ( polyarea ( $ n , $ a ) , 3 ) ; ? >