Found 34494 Articles for Programming

FILTER_SANITIZE_NUMBER_INT constant in PHP

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

493 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"

FILTER_SANITIZE_MAGIC_QUOTES constant in PHP

George John
Updated on 27-Jun-2020 08:34:08

235 Views

The FILTER_SANITIZE_MAGIC_QUOTES constant performs the addslashes() function to a string. It adds backslashes in front of predefined characters i.e. single quote ('), double quote ("), backslash (\), NULL.ReturnThe FILTER_SANITIZE_MAGIC_QUOTES constant does not return anything.Example Live Demo

FILTER_SANITIZE_ENCODED constant in PHP

Chandu yadav
Updated on 27-Jun-2020 08:38:21

195 Views

The FILTER_SANITIZE_ENCODED constant encodes special characters.Flags and OptionsFILTER_FLAG_STRIP_LOW − Remove characters with ASCII value less than 32FILTER_FLAG_STRIP_HIGH − Remove characters with ASCII value greater than 127FILTER_FLAG_ENCODE_LOW − Encode characters with ASCII value less than 32FILTER_FLAG_ENCODE_HIGH − Encode characters with ASCII value greater than 127ReturnThe FILTER_SANITIZE_ENCODED constant does not return anything.ExampleThe following is an example that use FILTER_FLAG_ENCODE_HIGH flag to encode characters with ASCII value > 127Example Live DemoOutputThe following is the output.www.example.comLet us see another example.Example Live DemoOutputHere is the output.example.comRead More

FILTER_SANITIZE_EMAIL constant in PHP

Arjun Thakur
Updated on 27-Jun-2020 08:40:01

306 Views

The FILTER_SANITIZE_EMAIL constant deletes all illegal characters from an email address.ReturnThe FILTER_SANITIZE_EMAIL constant does not return anything.ExampleOutputThe following is the output.abc@demo.com

Stack in Java Programming

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

188 Views

Stack is a subclass of Vector that implements a standard last-in, first-out stack. Stack only defines the default constructor, which creates an empty stack. Stack includes all the methods defined by Vector, and adds several of its own. Stack( ) Apart from the methods inherited from its parent class Vector, Stack defines the following methods − Sr.No. Method & Description 1 boolean empty() Tests if this stack is empty. Returns true if the stack is empty, and returns false if the stack contains elements. 2 Object peek( ) Returns the element ... Read More

Sorting a HashMap according to values in Java

Rishi Raj
Updated on 30-Jul-2019 22:30:23

519 Views

As we know that Hash map in Java does not maintain insertion order either by key or by order.Also it does not maintain any other order while adding entries to it. Now in order to sort a hash map according to the values mapped to its corresponding keys we first need to get all values of map considering that hash map has unique values only.Now put all the values in a list and sort this list with the comparator or comparable interface of Java. As we get sorted list of unique values now get corresponding keys from the map and ... Read More

FILTER_VALIDATE_URL constant in PHP

Ankith Reddy
Updated on 27-Jun-2020 08:24:36

245 Views

The FILTER_VALIDATE_URL constant validates a URL.FlagsFILTER_FLAG_SCHEME_REQUIRED − URL must be RFC compliant.FILTER_FLAG_HOST_REQUIRED − URL must include host name.FILTER_FLAG_PATH_REQUIRED −URL must have a path after the domain name.FILTER_FLAG_QUERY_REQUIRED −URL must have a query string.ReturnThe FILTER_VALIDATE_URL constant does not return anything.Example Live DemoOutputThe following is the output.Valid URL!Let us see another example.Example Live DemoOutputHere is the output.Invalid URL!

FILTER_VALIDATE_REGEXP constant in PHP

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

689 Views

The FILTER_VALIDATE_REGEXP constant validates a value against a Perl-compatible regular expression. Options regexp − The regular expression to validate against. Return The FILTER_VALIDATE_REGEXP constant does not return anything. Example Live Demo The following is the output. Matched String!

Advertisements