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
Articles on Trending Technologies
Technical articles with clear explanations and examples
Measuring Script Execution Time in PHP
In PHP, measuring script execution time is crucial for performance optimization and debugging. PHP provides several built−in functions to measure how long your code takes to execute, each with different levels of precision. Using microtime() Function The most commonly used method for measuring execution time with microsecond precision ? Script execution time: 0.045123 seconds Using time() Function For basic timing with second−level precision ? Script execution time: 2 seconds Using hrtime() Function (PHP 7.3+) The most precise method available, providing ...
Read MoreConvert an int to ASCII character in C/C++
In C, every character like 'A', 'b', '3', or '@' is stored as a number called its ASCII value. For example, 'A' is 65, and 'a' is 97. Given an integer like 97, we can convert it to its corresponding ASCII character which is 'a'. Syntax char character = (char)asciiValue; We can convert an integer to an ASCII character using simple methods. Here are two common approaches − Typecasting to Convert int to ASCII Character Using printf for int to ASCII Conversion Method 1: Typecasting to Convert int to ASCII Character ...
Read MoreMathematical Logical Terms and Definitions
Tautologies A Tautology is a formula which is always true for every value of its propositional variables. Example − Prove [ (A → B) ∧ A ] → B is a tautology The truth table is as follows − A B A → B (A → B) ∧ A [ (A → B) ∧ A ] → B True True True True True True False False False True False True True False True False False True False True As we can see every value ...
Read MoreInsert String at Specified Position in PHP
In PHP, you can insert a string at a specified position within another string using various methods. The most common approaches include string concatenation with substr() and the substr_replace() function. Using String Concatenation with substr() This method breaks the original string into two parts and concatenates the insert string between them − Hello beautiful World! The substr() function extracts portions before and after the specified position, then the dot operator concatenates all three parts together. Using substr_replace() Function The substr_replace() function provides a more direct approach for inserting ...
Read MoreHow to find the size of an int[] in C/C++?
In C programming, finding the size of a statically declared int[] array means determining how many elements it contains. This is different from finding the memory size − we want the element count. The sizeof operator is the primary method for this in C. Syntax int array_length = sizeof(array) / sizeof(array[0]); Method 1: Using sizeof Operator The sizeof operator returns the total memory occupied by an array in bytes. Dividing this by the size of one element gives us the number of elements. This works only for statically declared arrays − #include ...
Read MoreImplementing Callback in PHP
In PHP, callbacks are functions that can be passed as arguments to other functions and executed at a later time. This powerful feature allows for flexible and reusable code design. PHP offers multiple ways to implement callbacks depending on your specific needs. There are three common approaches to implement callbacks in PHP ? Callback Functions Anonymous Functions (Closures) Callable Objects Callback Functions Callback functions are regular named functions that can be passed as arguments to other functions. The receiving function can then execute the passed ...
Read MoreModulus of two float or double numbers using C
In C, to find the modulus (remainder) of two floating-point or double numbers, we use the remainder() function from the math library. Unlike the % operator which only works with integers, remainder() handles floating-point arithmetic. Syntax double remainder(double x, double y); float remainderf(float x, float y); long double remainderl(long double x, long double y); Parameters x − The numerator (dividend) y − The denominator (divisor) Return Value Returns the floating-point remainder of x/y. The remainder is calculated as: remainder(x, y) = x - rquote * y ...
Read MoreHow to Use a Switch case \'or\' in PHP
In PHP, the switch-case statement does not directly support the logical OR (||) operator to combine multiple cases. However, there are several effective approaches you can use to achieve similar functionality when you need multiple values to trigger the same action. Using If-Else Statements Instead of using a switch statement, you can utilize if-else statements with logical "or" operators ? Value is 1, 2, or 3 We define an array $validValues that contains the values we want to check against. The in_array() function determines if $value exists within the array. ...
Read Moretrunc() , truncf() , truncl() in C language
In C, the trunc(), truncf(), and truncl() functions are used to truncate floating-point values, removing the fractional part and returning only the integer portion. These functions are part of the math.h library and are available in C99 and later standards. Installation: These functions require C99 or later. Compile with gcc -std=c99 -lm to link the math library. Syntax double trunc(double x); float truncf(float x); long double truncl(long double x); Parameters x − The floating-point value to be truncated Return Value Returns the truncated value (integer part) as ...
Read MoreHow to Test a URL for 404 error in PHP?
In PHP, testing a URL for 404 errors is essential for validating links and ensuring proper user experience. PHP offers several methods to check URL status codes, each with different levels of efficiency and control. Using file_get_contents() The simplest approach uses file_get_contents() with a custom stream context to handle errors gracefully ? This method creates a stream context with ignore_errors set to true, preventing PHP from throwing warnings on HTTP errors. The $http_response_header variable is automatically populated with headers from the last HTTP request. Using get_headers() A more efficient approach using ...
Read More