Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
PHP Articles
Page 42 of 81
What is the meaning and usage of '=&' assignment operator in PHP?
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 MorePHP Predefined Mathematical Constants
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 MorePHP tan() Function
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 MorePHP srand() Function
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 MorePHP sqrt() Function
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 MorePHP sin() Function
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 MorePHP round() Function
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 MorePHP pow() Function
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 MorePHP pi() Function
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 MorePHP mt_srand() Function
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