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 44 of 81
PHP decbin() Function
The decbin() function converts a decimal number to its binary representation and returns it as a string. This function is useful for displaying numbers in binary format or for bitwise operations. Syntax decbin ( int $number ) : string Parameters Parameter Description number A decimal number to be converted to binary representation Return Value Returns a string containing the binary representation of the given decimal number. Examples Basic Usage Here's how to convert positive decimal numbers to binary ? ...
Read MorePHP cos() Function
The cos() function returns the cosine ratio of given angle in radians. In trigonometry, cosine of an angle is defined as ratio of lengths of adjacent side and hypotenuse. cos(x) = adjacent/hypotenuse If x=90 degrees (π/2 radians), cos(x) = 0. This function returns a float value. Syntax cos ( float $arg ) : float Parameters Parameter Description arg A floating point value that represents angle in radians Return Value PHP cos() function returns cosine ratio of given parameter as a float. Examples ...
Read MorePHP ceil() Function
The ceil() function is a built-in mathematical function in PHP that rounds any float number up to the next highest integer. This function always returns a float number, as the range of float is larger than that of integer. Syntax ceil ( float $num ) : float Parameters Parameter Description num The number to be rounded up Return Value The ceil() function returns the smallest integer value (as float) that is greater than or equal to the given parameter. Examples Example 1: Basic Usage ...
Read MorePHP bindec() Function
The bindec() function converts a binary number represented as a string into its decimal equivalent. The binary string is interpreted as an unsigned integer, and invalid characters (other than 0 and 1) are ignored. Syntax bindec(string $binary_string): int|float Parameters Parameter Description binary_string A string containing binary digits (0 and 1). Invalid characters are ignored. Return Value Returns the decimal equivalent as an integer or float (for large numbers). Examples Basic Usage Converting a simple binary string to decimal ? ...
Read MorePHP asinh() Function
The asinh() function calculates the inverse hyperbolic sine of a given number. In mathematical terms, it returns the value whose hyperbolic sine equals the input parameter. The mathematical formula is: asinh(x) = log(x + sqrt(x² + 1)) Syntax asinh(float $arg): float Parameters Parameter Description arg A floating point value whose inverse hyperbolic sine is to be calculated Return Value Returns the inverse hyperbolic sine of the argument as a float value. Examples Basic Usage Here's a simple example using the value of ...
Read MorePHP acosh() Function
The acosh() function returns the inverse hyperbolic cosine of a given number. The inverse hyperbolic cosine is defined mathematically as: acosh(x) = log(x + sqrt(x² - 1)) This function accepts values greater than or equal to 1 and returns a float value representing the hyperbolic angle in radians. Syntax acosh(float $arg): float Parameters Parameter Description arg A floating point value ≥ 1 whose inverse hyperbolic cosine is to be calculated Return Value Returns the inverse hyperbolic cosine of arg as a float, or NAN ...
Read MorePHP abs() Function
The abs() function is a built-in PHP function that returns the absolute value of a number. The absolute value is always positive, regardless of whether the input is positive or negative. Syntax abs(mixed $number) Parameters Parameter Description number The numeric value to process (int, float, or numeric string) Return Value Returns the absolute value of the number. If the parameter is a float, the return type is float. For integer parameters, the return type is integer. Examples Basic Usage with Numbers ...
Read MoreDifference between bindParam and bindValue in PHP
Both bindParam() and bindValue() are built-in PHP PDO methods used to bind variables to placeholders in prepared SQL statements. While they appear similar, they handle variable binding differently − one binds by reference, the other by value. Key Differences Sr. No. Key bindParam() bindValue() 1 Binding Type Binds by reference − uses variable's current value at execution Binds by value − captures value at bind time 2 When Value is Read At execute() time At bindValue() call time 3 Variable Changes Reflects changes made to variable after ...
Read MoreHow to prevent multiple inserts when submitting a form in PHP?
PHP provides several methods to prevent multiple inserts when users accidentally submit forms multiple times. The most common approaches include using sessions with timestamps, CSRF tokens, and database constraints. Method 1: Using Session Timestamps This method tracks the last form submission time to prevent duplicate submissions within a specified time window − Method 2: Using CSRF Tokens This approach generates unique tokens for each form to ensure single−use submissions −
Read MorePHP Casting Variable as Object type in foreach Loop
In PHP, you can cast variables as specific object types within foreach loops to improve IDE autocompletion and code clarity. This is particularly useful when working with arrays of objects where the IDE needs hints about the object type. Using @var Annotation Most IDEs like NetBeans and IntelliJ support @var annotations in comments to specify variable types − Alice - alice@example.com Bob - bob@example.com Using @return Annotation You can also use @return annotations in methods that return arrays of objects − User: John ...
Read More