PHP Articles

Page 42 of 81

What is the meaning and usage of '=&' assignment operator in PHP?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 994 Views

The =& operator in PHP creates a reference assignment, where two variables point to the same data location in memory instead of copying the value. This is known as "assignment by reference" and helps avoid data redundancy by making both variables share the same underlying data. Syntax The syntax for reference assignment is − Basic Example Here's how reference assignment works with simple variables − my_val1: 89 my_val2: 89 Reference vs Copy Assignment Let's compare reference assignment with regular copy assignment − ...

Read More

PHP Predefined Mathematical Constants

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 256 Views

PHP provides a comprehensive set of predefined mathematical constants that are essential for mathematical calculations. These constants are globally available and provide precise values for common mathematical operations. Core Mathematical Constants The most commonly used mathematical constants include pi, Euler's number, and their derivatives ?

Read More

PHP tan() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 216 Views

The tan() function returns the tangent ratio of a given angle in radians. In trigonometry, tangent of an angle is defined as the ratio of lengths of opposite side and adjacent side. tan(x) = opposite/adjacent Tangent of an angle is also defined as the ratio of its sine and cosine: tan(x) = sin(x)/cos(x) If x = 45 degrees, tan(x) = 1, as in a right-angled triangle, opposite and adjacent sides are equal. This function returns a float value. Syntax tan ( float $arg ) : float Parameters ...

Read More

PHP srand() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 395 Views

The srand() function is used to seed the random number generator in PHP. Seeding initializes the random number generator with a specific starting value, ensuring reproducible or truly random sequences. While seeding is done automatically in modern PHP versions, manual seeding gives you control over randomization. Syntax srand([ int $seed ]) : void Parameters Parameter Description Required seed An integer to be used as seed. If not provided, a random number is used automatically Optional Return Value This function doesn't return any value (void). Examples ...

Read More

PHP sqrt() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 2K+ Views

The sqrt() function returns the square root of a positive float number. Since square root for negative numbers is not defined, it returns NAN (Not a Number). This is one of the most commonly used mathematical functions in PHP. This function always returns a floating point number. Syntax sqrt ( float $arg ) : float Parameters Parameter Description arg A number whose square root is to be obtained Return Values PHP sqrt() function returns the square root of the given arg number. For negative numbers, ...

Read More

PHP sin() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 311 Views

The sin() function returns the sine of a given angle in radians. In trigonometry, sine of an angle is defined as the ratio of the length of the opposite side to the hypotenuse in a right triangle. sin(x) = opposite/hypotenuse For example, if x = 90 degrees (π/2 radians), sin(x) = 1, as the opposite side equals the hypotenuse in this case. This function returns a float value. Syntax sin(float $arg): float Parameters Parameter Description arg A floating point value representing the angle in radians ...

Read More

PHP round() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 1K+ Views

The round() function proves useful in rounding any floating point number up to a desired precision level. Positive precision parameter causes the number to be rounded after decimal point, whereas with negative precision, rounding occurs before decimal point. Precision is 0 by default. For example, round(10.6) returns 11, round(10.2) returns 10. The function always returns a floating point number. Syntax round(float $value, int $precision = 0, int $mode = PHP_ROUND_HALF_UP): float Parameters Parameter Description value A float number to be rounded precision Number of decimal digits to ...

Read More

PHP pow() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 1K+ Views

The pow() function is used to compute the power of a certain number. It returns xy calculation, also termed as x raised to y. PHP also provides "**" as an exponentiation operator. So, pow(x, y) returns xy which is same as x**y Syntax pow ( number $base , number $exp ) : number Parameters Sr.No Parameter & Description 1 baseThe base to be raised 2 expPower to which base needs to be raised Return Value PHP pow() function returns base raised to power ...

Read More

PHP pi() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 534 Views

The pi() function returns the value of mathematical constant π (pi). It returns a float value 3.14159265359 which is equal to the predefined constant M_PI in PHP. Syntax pi() : float Parameters This function requires no parameters. Return Value The pi() function returns the mathematical constant π as a float value. This is equivalent to using the predefined constant M_PI, providing a convenient function-based alternative for mathematical calculations. Example Here's how to use the pi() function in mathematical calculations − The output of the above ...

Read More

PHP mt_srand() Function

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 478 Views

The mt_srand() function seeds the Mersenne Twister random number generator in PHP. The prefix 'mt' stands for Mersenne Twister, which is a high−quality pseudorandom number generator algorithm. While seeding is optional in PHP (done automatically), manual seeding ensures reproducible random sequences or better randomization. Syntax mt_srand ([ int $seed [, int $mode = MT_RAND_MT19937 ]] ) : void Parameters Parameter Description seed (optional) Integer value used as seed. If omitted, a random number is used mode (optional) MT_RAND_MT19937: Uses fixed Mersenne Twister implementationMT_RAND_PHP: Uses default PHP implementation ...

Read More
Showing 411–420 of 802 articles
« Prev 1 40 41 42 43 44 81 Next »
Advertisements