Found 34490 Articles for Programming

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

274 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

212 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

533 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

FILTER_SANITIZE_NUMBER_INT constant in PHP

George John
Updated on 27-Jun-2020 08:46:14

494 Views

The FILTER_SANITIZE_NUMBER_INT constant deletes all illegal characters from a number.ReturnThe FILTER_SANITIZE_NUMBER_INT constant does not return anything.Example Live DemoOutputThe following is the output.string(5) "4-5+9"

Static methods vs Instance methods in Java

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

2K+ Views

In Java as we know that the behavior of any variable/method is defined by the keyword that is used in front of its declaration name. So one of the non-access modifiers is Static which can be used along with method as well as with variable. Static methods as name states defined at the class level and could be accessed on the class name i.e no need of class object creation in order to access/call the static methods. While on another hand if we do not uses the static keyword with variable/method than it belongs or categorized as instance method which ... Read More

FILTER_SANITIZE_NUMBER_FLOAT constant in PHP

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

329 Views

The FILTER_SANITIZE_NUMBER_FLOAT constant deletes all illegal characters from a float number.FlagsFILTER_FLAG_ALLOW_FRACTION − Allows fraction separatorFILTER_FLAG_ALLOW_THOUSAND − Allows thousand separatorFILTER_FLAG_ALLOW_SCIENTIFIC − Allows scientific notationReturnThe FILTER_SANITIZE_NUMBER_FLOAT constant does not return anything.ExampleThe following is an example that use FILTER_FLAG_ALLOW_FRACTION flag. Live DemoOutputThe following is the output.string(8) "3-1+2.56"Let us see another example. Here, FILTER_FLAG_ALLOW_THOUSAND flag is used −Example Live DemoOutputHere is the output.string(8) "1-4+25,6"

Advertisements