Highest power of 2 less than or equal to given number | PHP program to find highest power of 2 smaller than or equal to n . ; Driver code
< ? php function highestPowerof2 ( $ n ) { $ p = ( int ) log ( $ n , 2 ) ; return ( int ) pow ( 2 , $ p ) ; } $ n = 10 ; echo highestPowerof2 ( $ n ) ; ? >