Programming Articles

Page 1046 of 2547

PHP asinh() Function

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

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 More

PHP acosh() Function

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

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 More

PHP abs() Function

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

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 More

Difference between bindParam and bindValue in PHP

Nitin Sharma
Nitin Sharma
Updated on 15-Mar-2026 4K+ Views

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 More

How to prevent multiple inserts when submitting a form in PHP?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 2K+ Views

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 More

PHP Casting Variable as Object type in foreach Loop

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

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

In PHP, how can I add an object element to an array?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 3K+ Views

In PHP, you can add an object element to an array using several methods. The most common approach is to create an object and then append it to an array using the array push syntax. Method 1: Using stdClass Object Create a standard object and add it to an array ? Array ( [0] => a [1] => c [2] => stdClass Object ( ...

Read More

Detect language from string in PHP

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

Detecting the language of a text string in PHP can be achieved using specialized libraries. While character-based detection isn't reliable, the Text_LanguageDetect PEAR package provides decent accuracy for language identification. Installation: Install the Text_LanguageDetect package using PEAR: pear install Text_LanguageDetect Using Text_LanguageDetect Package The Text_LanguageDetect package analyzes text patterns to identify the most likely languages ? Output The output shows detected languages with confidence scores ? Array ( [english] => 0.668518518519 [german] => 0.407037037037 [dutch] ...

Read More

How to read only 5 last line of the text file in PHP?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 735 Views

In PHP, you can read only the last 5 lines of a text file using the file() function combined with array slicing. The file() function reads the entire file into an array where each line becomes an array element. Using file() Function This method loads the entire file into memory and extracts the last 5 lines ? Using array_slice() Method A more concise approach using array_slice() to get the last 5 elements ? Memory-Efficient Method for Large Files For very large files, reading line by line ...

Read More

How to download large files through PHP script?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 3K+ Views

Downloading large files through PHP requires careful memory management to avoid script timeouts and memory exhaustion. The key is to read and output the file in small chunks rather than loading it entirely into memory. Chunked File Download Function Here's a function that downloads large files by reading them in chunks − Complete Download Script with Headers For actual file downloads, you need proper HTTP headers −

Read More
Showing 10451–10460 of 25,466 articles
Advertisements