Found 34494 Articles for Programming

constant() function in PHP

Arjun Thakur
Updated on 27-Jun-2020 08:50:44

189 Views

The constant() function returns the value of a constant.Syntaxconstant(const)Parametersconst − The name of the constant to checkReturnThe constant() function returns the value of a constant and NULL if the constant is not defined.ExampleThe following is an example that defines a constant. Live DemoOutputThe following is the output.This is it!

FILTER_CALLBACK constant in PHP

Ankith Reddy
Updated on 27-Jun-2020 08:51:17

83 Views

The FILTER_CALLBACK constant calls a user defined function to filter the value.ReturnThe FILTER_CALLBACK constant does not return anything.ExampleThe following is an example that converts the case of a string. Here, existing function in PHP is taken. Live DemoOutputThe following is the output.demo text!

FILTER_SANITIZE_URL constant in PHP

George John
Updated on 27-Jun-2020 08:52:04

296 Views

The FILTER_SANITIZE_URL constant removes all illegal URL characters from a string. It allows the following −$-_.+!*'(),{}|\^~[]`">

FILTER_SANITIZE_STRIPPED constant in PHP

Chandu yadav
Updated on 27-Jun-2020 08:53:04

120 Views

The FILTER_SANITIZE_STRIPPED constant encodes or strips unwanted characters.Options and FlagsFILTER_FLAG_NO_ENCODE_QUOTES − This flag does not encode quotesFILTER_FLAG_STRIP_LOW − Strips characters with ASCII value below 32FILTER_FLAG_STRIP_HIGH − Strips characters with ASCII value above 32FILTER_FLAG_ENCODE_LOW − Encodes characters with ASCII value below 32FILTER_FLAG_ENCODE_HIGH − Encodes characters with ASCII value above 32FILTER_FLAG_ENCODE_AMP − Encodes the & character to &ReturnThe FILTER_SANITIZE_STRIPPED constant does not return anything.Example Live DemoOutputThe following is the output.string(10) "Demo!text!"

Swapping Characters of a String in Java

Vikyath Ram
Updated on 30-Jul-2019 22:30:23

3K+ Views

For swapping characters of a string in Java we can use string builder which is mutable so we need not to take care of new object creation during swapping. In this we would create a method which swap characters of string based on location of swapping characters.This method will take location of swapping characters as its parameters.First store both characters need to be swapped and using set character method of string builder swap the targeted characters. Example Live Demo public class SwapCharacters { public static void main(String[] args) { ... Read More

FILTER_SANITIZE_STRING constant in PHP

Arjun Thakur
Updated on 27-Jun-2020 08:53:49

273 Views

The FILTER_SANITIZE_STRING constant deletes tags and encodes special characters from a string.FlagsFILTER_FLAG_NO_ENCODE_QUOTES − Do not encode quotesFILTER_FLAG_STRIP_LOW − Removes characters with ASCII value less than 32FILTER_FLAG_STRIP_HIGH − Removes characters with ASCII value greater than 127FILTER_FLAG_ENCODE_LOW − Encodes characters with ASCII value less than 32FILTER_FLAG_ENCODE_HIGH − Encodes characters with ASCII value greater than 127FILTER_FLAG_ENCODE_AMP − Encodes the "&" character to &ReturnThe FILTER_SANITIZE_STRING constant does not return anything.Example Live DemoOutputThe following is the output.Demo!

Swap two variables in one line in Java

Jai Janardhan
Updated on 30-Jul-2019 22:30:23

1K+ Views

In order to swap two variable using single expression or in single line we could use bitwise XOR operator of Java. As we now that in Java XOR functions as XOR of two numbers a and b returns a number which has all the bits as 1 wherever bits of a and b differs. So for swapping of two variable we would use this operator as Example Live Demo public class SwapUsingBitwise { public static void main(String[] args) { int a = 8 ; int b = 10; ... Read More

Swap two Strings without using third user defined variable in Java

Arushi
Updated on 30-Jul-2019 22:30:23

211 Views

In order to swap two strings i.e interchange the content of two strings we will use sub string method of string class in Java.First of all get the length of both strings before making any change in any of string.Now modify one string as concatenate both strings and assign to one string. After this use sub string method of String class using begin index as length of new modified string 1 and last index as initial length of string 1.This will give us the swiped string 1 which contain content of string 2. Now to get swiped string 2 again ... Read More

FILTER_SANITIZE_SPECIAL_CHARS constant in PHP

Ankith Reddy
Updated on 27-Jun-2020 08:43:48

531 Views

The FILTER_SANITIZE_SPECIAL_CHARS constant filter HTML-escapes special characters.FlagsFILTER_FLAG_STRIP_LOW − Strip characters with ASCII value below 32FILTER_FLAG_STRIP_HIGH − Strip characters with ASCII value above 32FILTER_FLAG_ENCODE_HIGH − Encode characters with ASCII value above 32ReturnThe FILTER_SANITIZE_SPECIAL_CHARS constant does not anything.Example Live DemoOutputThe following is the output.string(43) "Favorite Sports is Football & Cricket?"

Streams in Java

Fendadis John
Updated on 30-Jul-2019 22:30:23

1K+ Views

Stream is a new abstract layer introduced in Java 8. Using stream, you can process data in a declarative way similar to SQL statements. For example, consider the following SQL statement. SELECT max(salary), employee_id, employee_name FROM Employee The above SQL expression automatically returns the maximum salaried employee's details, without doing any computation on the developer's end. Using collections framework in Java, a developer has to use loops and make repeated checks. Another concern is efficiency; as multi-core processors are available at ease, a Java developer has to write parallel code processing that can be pretty error-prone. To resolve ... Read More

Advertisements