Found 34490 Articles for Programming

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

308 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

520 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

693 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!

FILTER_VALIDATE_IP constant in PHP

Chandu yadav
Updated on 30-Jul-2019 22:30:23

450 Views

The FILTER_VALIDATE_IP constant validates an IP address. Flags FILTER_FLAG_IPV4 − The value must be a valid IPv4 address FILTER_FLAG_IPV6 − The value must be a valid IPv6 address FILTER_FLAG_NO_PRIV_RANGE − The value must not be within a private range FILTER_FLAG_NO_RES_RANGE − The value must not be within a reserved range Return The FILTER_VALIDATE_IP constant does not return anything. Example Live Demo The following is the output. Invalid IP address! Let us see another example. Live Demo Here is the output. Valid IP address!

Sorting collection of String and StringBuffer in Java

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

603 Views

In order to sort in Java as we know we can use either Comparable or Comparator interfaces in which we could also define our custom logic to sort.One of the approach to sort is to add the entity in TreeSet or TreeMap which would sort the entries as internally they also uses the comparable interface. Now String class in Java internally implements comparable interface so whenever we add string to a tree set or map it uses comparable logic of string class and sort the input entry strings.But String buffer do not have the implementation of comparable interface so ... Read More

FILTER_VALIDATE_INT constant in PHP

Arjun Thakur
Updated on 27-Jun-2020 08:30:08

740 Views

The FILTER_VALIDATE_INT constant validates value as integer.Options and flagsmin_range − The minimum integer valuemax_range − The maximum integer valueFILTER_FLAG_ALLOW_OCTAL − Allows octal number valuesFILTER_FLAG_ALLOW_HEX − Allows hexadecimal number valuesReturnThe FILTER_VALIDATE_INT constant does not return anything.Example Live DemoOutputThe following is the output.float(3.5) Integer VariableLet us see another example.Example Live DemoOutputHere is the output.Accepted range!

Advertisements