Programming Articles - Page 1005 of 3366

PHP – grapheme_strlen() function

Urmila Samariya
Updated on 12-Oct-2021 06:54:56

321 Views

A grapheme is the smallest functional unit of a writing system. Graphemes can be interpreted as the smallest units of writing that correspond with sounds.The grapheme_strlen() function in PHP is used to get the string length in grapheme units. This function does not get the byte or character's length. The grapheme_strlen function is supported in PHP 5.3.0 and higher versions.Syntaxinteger grapheme_strlen($str_string)Parametersgrapheme_strlen() accepts only one parameter −$str_string − The string parameter is used to measure the length of the string and it must use a UTF-8 encoding string.Return ValuesThis function returns the length of the string on success or it returns ... Read More

PHP – idn_to_ascii() function

Urmila Samariya
Updated on 12-Oct-2021 06:50:44

572 Views

The idn_to_ascii() function in PHP is used to convert a Unicode domain name into IDNA ASCII form. IDNA stands for Internationalizing Domain Names in Applications. It is a mechanism for handling internationalized domain names containing nonASCII characters.Syntaxstring idn_to_ascii( str $domain, integer $flags=IDNA_DEFAULT, integer $variant=INTL_IDNA_VARIANT_UTS46, arr &$idna_info=null )Parametersidn_to_ascii() accepts the following four parameters −$domain − This is the domain to be converted; it must be UTF-8 encoded.$flags − This parameter is a combination of IDNA_*constants.$variant − This parameter uses either INTL_IDNA_VARIANT_2003 for IDNA 2003 or INTL_IDNA_VARIANT_UTS46 for UTS#46.$idna_info − ... Read More

PHP – exif_imagetype() function

Urmila Samariya
Updated on 12-Oct-2021 06:46:33

953 Views

The EXIF (Exchangeable image file format) PHP extension enables to work with the metadata from the images taken by digital devices like digital cameras, cell phones, etc. It depends on the image file format. We can retrieve embedded thumbnails of images.The exif_imagetype() function in PHP is used to determine the type of an image. This function reads the first bytes of a given image and checks its signature. It can also be used to avoid calls to other EXIF functions with unsupported file types or in conjunction with $_server['http_accept'] to check whether or not the viewer can see the specific ... Read More

C++ program to demonstrate exception handling

Arnab Chakraborty
Updated on 12-Oct-2021 06:53:43

387 Views

Suppose there is a function that calculates some serious complex mathematical operations. But during the operations, some exceptions can occur. We have to handle the different types of exceptions that can occur and perform the following.If the computer is unable to allocate the memory for computation, we have to print 'Memory Low!'If any other C++-related exception occurs, we have to print 'Exception:' then the exception.If something else happens, we print 'Unhandled exception'.We are given an array that contains a pair of values, and we pass it to the function. If any exception occurs, we handle it, or otherwise, we print ... Read More

PHP – exif_read_data() function

Urmila Samariya
Updated on 12-Oct-2021 06:42:12

1K+ Views

The exif_read_data() function in PHP reads the EXIF (Exchangeable image file format) headers from an image file. This function extracts all the EXIF headers from an image file.SyntaxArray exif_read_data( str $file, str $section=null, bool $arrays=false, bool $thumbnail=false )Parametersexif_read_data() accepts the following four parameters −$file − This parameter is used to specify the location of an image file.$section − This parameter specifies a comma-separated list of sections that need to be present in the file to produce a resultant array.$arrays − This parameter specifies whether or not to present ... Read More

PHP – How to get or set the path of a domain?

Urmila Samariya
Updated on 12-Oct-2021 06:39:00

658 Views

The bindtextdomain() function in PHP is used to set or get the path of a domain.Syntaxstring bindtextdomain($str_domain, $str_directory)Parametersbindtextdomain() accepts two parameters −$str_domain − This is the domain.$str_directory − This is the directory path. If the directory path is NULL, then it will return the currently set directory.Return Valuesbindtextdomain() returns the full specified pathname for the domain which is currently set. It will return False on the failure.ExampleOutputC:\xampp\htdocs

PHP – mb_ereg_search_init() function

Urmila Samariya
Updated on 12-Oct-2021 06:37:13

146 Views

The mb_ereg_search_init() function in PHP is used to setup string and regular expression pattern for a multibyte regular expression match. The values are used for mb_ereg_search_regs, mb_ereg_search_pos, and mb_ereg_search.Syntaxbool mb_ereg_search_init( $str_string, $str_pattern=null, $str_options=null )Parametersmb_ereg_search_init() accepts three parameters −string − This is the search string.pattern − This is the search pattern.options − This is the search option. .Return Valuesmb_ereg_search_init() returns True on success and False on failure.ExampleOutputbool(true) bool(true)

PHP – mb_strcut() function

Urmila Samariya
Updated on 12-Oct-2021 06:35:18

483 Views

The mb_strcut() function in PHP is used to get a part of a specified string. It extracts the substring from a given string. It operates on bytes instead of characters. If the cut position happens to be between two bytes of multi-byte characters, then the cut is achieved starting from the first byte of those characters.Syntaxstring mb_strcut( $str_string, $int_start, $int_length=null, $str_encoding=null );For example:mb_strcut( string="Onlinetutorial", int= 6, length=5, encoding= "UTF-8" );Parametersmb_strcut() accepts the following four parameters −str_string ... Read More

PHP – mb_strripos() function

Urmila Samariya
Updated on 12-Oct-2021 06:31:04

181 Views

The mb_strripos() function in PHP is used to search the last existing of a string in another string. This function is not case-sensitive. It performs multi-byte safe strripos() operation based on the number of characters. It returns the specified needle position count from the starting of the haystack string.Syntaxinteger mb_strripos( $str_haystack, $str_needle, $integer_offset=0, $str_encoding )Parametersmb_strripos() accepts the following four parameters −str_haystack − It is the string used to get the position of the last occurrence of the string needle.str_needle − This is used to find the string from ... Read More

C++ program to demonstrate function of macros

Arnab Chakraborty
Updated on 12-Oct-2021 13:48:40

497 Views

Suppose we are given a integer array that contains several integer values. We have to find out the difference between the smallest value and the largest value in the array. To solve this problem, we have to use macros. The inputs are taken from stdin, and the result is printed back to stdout.So, if the input is like array = {120, 589, 324, 221, 234}, then the output will be The answer is : 469The difference between the largest value 589 and the smallest value 120 is 469.To solve this, we will follow these steps −mini := infinitymaxi := negative ... Read More

Advertisements