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
Server Side Programming Articles
Page 1001 of 2109
PHP – mb_ereg_replace() function – Replace regular expression with multibyte support
In PHP, mb_ereg_replace() is used to replace a regular expression with multibyte support. It scans the string for matches to pattern, then replaces the matched text with the replacement, making it ideal for handling international characters and Unicode strings. Syntax string mb_ereg_replace(string $pattern, string $replacement, string $string, string $options = null) Parameters The function accepts the following four parameters − $pattern − The regular expression pattern. It may use multibyte characters in the pattern. $replacement − The replacement text used to replace the matched pattern. $string − The input string to be ...
Read Morepow() function in C
The pow() function in C is used to calculate the power of a number. It computes base raised to the power of exponent and returns the result as a double. This function is declared in the math.h header file. Syntax double pow(double base, double exponent); Parameters base − The base value whose power is to be calculated exponent − The power value (exponent) Return Value Returns the value of base raised to the power of exponent as a double. Example 1: Basic Usage Here is a simple example ...
Read MorePHP – mb_ereg_replac_callback() function
In PHP, mb_ereg_replace_callback() function is used to perform a regular expression search and replace with multibyte support using a callback. It scans strings, matches them with a pattern, then replaces the matched text with the output of the callback function. This function is similar to mb_ereg_replace() but allows custom replacement logic through callbacks. It is supported in PHP 5.4 or higher versions. Syntax string mb_ereg_replace_callback(str $pattern, callback $callback, str $string, str $options) Parameters The function accepts the following four parameters − $pattern − The regular expression pattern. May use multibyte characters. $callback ...
Read MoreStatic functions in C
A static function in C is a function that has a scope limited to its object file. This means the static function is only visible within the file where it is defined and cannot be accessed from other files. A function can be declared as static by placing the static keyword before the function name. Syntax static return_type function_name(parameters) { // function body } Example 1: Static Function in Same File Here's an example demonstrating a static function called within the same file − #include static ...
Read MorePHP – Match regular expression using mb_ereg_match()
In PHP, the mb_ereg_match() function is used for matching a given string with a regular expression pattern. This function only matches the string from the beginning and returns true if a match is found, else it returns false. It supports multibyte character sets, making it useful for international text processing. Syntax bool mb_ereg_match(string $pattern, string $string, string $options = null) Parameters It accepts the following three parameters − $pattern − The regular expression pattern to match against. $string − The input string being evaluated. ...
Read Moreexit(), abort() and assert() in C/C++
In C programming, the exit(), abort(), and assert() functions are used for program termination and debugging. Each function serves a different purpose and is defined in different header files. The exit() Function The exit() function is used to terminate a program immediately in a normal way. It is defined in the header file and allows the program to return a status code to the operating system. Syntax void exit(int status_value); Parameters: status_value − The termination status code (0 indicates success, non-zero indicates error) Example In this example, the ...
Read MorePHP – Get aliases of a known encoding type using mb_encoding_aliases()
In PHP, mb_encoding_aliases() is used to get the aliases of a known encoding type. This function returns all alternative names for a specified character encoding, which is useful when working with different systems that may use varying naming conventions for the same encoding. Syntax array mb_encoding_aliases(string $encoding) Parameters $encoding − The encoding type to check for aliases. This must be a valid encoding name recognized by the mbstring extension. Return Value Returns a numerically indexed array of encoding aliases on success, or false on failure. Errors/Exceptions If the encoding is ...
Read MorePHP – Encode string for MIME header using mb_encode_mimeheader()
In PHP, mb_encode_mimeheader() function is used to encode a string for MIME (Multipurpose Internet Mail Extensions) header. It encodes a given string by the MIME header encoding scheme, which is essential for email headers containing non-ASCII characters. Syntax string mb_encode_mimeheader( string $string, ?string $charset = null, ?string $transfer_encoding = null, string $newLine = "\r", int $indent = 0 ) Parameters The mb_encode_mimeheader() function accepts five parameters − $string − The string to ...
Read MoreSwap two variables in one line in C/C+
In C programming, swapping two variables means exchanging the values stored in them. There are multiple ways to implement swapping using a single line statement. This article demonstrates various approaches to swap variable values efficiently. Syntax // General concept variable1 = new_value_of_variable2; variable2 = new_value_of_variable1; Example Scenario Let's consider the following input and expected output − Input: int a = 5; int b = 10; Output: a = 10 b = 5 Method 1: Using Arithmetic Operations This method uses arithmetic operations to swap variables without temporary storage. ...
Read MorePHP – How to detect character encoding using mb_detect_encoding()
In PHP, mb_detect_encoding() is used to detect the character encoding of a string from an ordered list of candidates. This function is particularly useful when working with multibyte encodings where not all byte sequences form valid strings. If the input contains invalid sequences for a particular encoding, that encoding is rejected and the next one is tested. Syntax string mb_detect_encoding(string $string, array|string|null $encoding_list = null, bool $strict = false) Note: Character encoding detection is not entirely reliable without additional context. It's similar to decoding encrypted data without a key. A Content-Type HTTP header can provide ...
Read More