Showing posts with label functions. Show all posts
Showing posts with label functions. Show all posts

Mar 12, 2016

Javascript pow() function

In Javascript if you want to rise a number to a power then you have to use one of the functions from Math module: Math.pow()

The Math.pow() function returns the base to the exponent power, that is, base exponent.

Syntax

Math.pow(base, exponent)

Parameters

base
The base number.
exponent
The exponent used to raise the base.

Description

Because pow() is a static method of Math, you always use it as Math.pow(), rather than as a method of aMath object you created (Math has no constructor).
Examples:
Math.pow(4,3);   // 4 * 4 * 4 = 48

Apr 19, 2011

PHP functions - eregi

eregi() -   became deprecated starting PHP 5.3.0

hmmm... I've used this function many times.

Mar 9, 2011

PHP number of days of a month

If you want to obtain number of days of a month, in PHP, you can use cal_days_in_month function:


int cal_days_in_month ( int $calendar , int $month , int $year )







So, here we have one example of usage of this function:


$num = cal_days_in_month(CAL_GREGORIAN, 8, 2003); // 31
    echo "There was $num days in August 2003";
?>