AmitDiwan has Published 10744 Articles

Boolean.Parse() Method in C#

AmitDiwan

AmitDiwan

Updated on 24-Apr-2020 11:11:22

1K+ Views

The Boolean.Parse() method in C# is used to convert the specified string representation of a logical value to its Boolean equivalent.SyntaxFollowing is the syntax −public static bool Parse (string val);Above, the parameter value is a string containing the value to convert.ExampleLet us now see an example to implement the Boolean.Parse() ... Read More

DateTimeOffset.FromFileTime() Method in C#

AmitDiwan

AmitDiwan

Updated on 21-Apr-2020 10:58:38

54 Views

The DateTimeOffset.FromFileTime() method in C# is used to convert the specified Windows file time to an equivalent local time.SyntaxFollowing is the syntax −public static DateTimeOffset FromFileTime (long time);Above, time is the Windows file time, in ticks.ExampleLet us now see an example to implement the DateTimeOffset.FromFileTime() method −using System; public class ... Read More

Type.GetEnumName() Method in C#

AmitDiwan

AmitDiwan

Updated on 21-Apr-2020 10:57:50

73 Views

The Type.GetEnumName() method in C# returns the name of the constant that has the specified value, for the current enumeration type.SyntaxFollowing is the syntax −public virtual string GetEnumName (object val);Above, Val is the value whose name is to be retrieved.ExampleLet us now see an example to implement the Type.GetEnumName() method ... Read More

DateTime.ToFileTimeUtc() Method in C#

AmitDiwan

AmitDiwan

Updated on 21-Apr-2020 08:02:41

239 Views

The DateTime.ToFileTimeUtc() method in C# is used to convert the value of the current DateTime object to a Windows file time.SyntaxFollowing is the syntax −public long ToFileTimeUtc ();ExampleLet us now see an example to implement the DateTime.ToFileTimeUtc() method −using System; public class Demo {    public static void Main() { ... Read More

Check if a PHP cookie exists and if not set its value

AmitDiwan

AmitDiwan

Updated on 09-Apr-2020 13:51:39

2K+ Views

Based on the PHP manual, the existence of a cookie can’t be found.A reference from the manual: “Once the cookies have been set, they can be accessed on the next page load with the $_COOKIE or $HTTP_COOKIE_VARS arrays.”The reason being cookies are response headers to the browser and the browser ... Read More

Access variables from parent scope in anonymous PHP function

AmitDiwan

AmitDiwan

Updated on 09-Apr-2020 13:43:42

586 Views

The ‘use’ keyword can be used to bind variables into the specific function’s scope.Use the use keyword to bind variables into the function's scope −Example Live Demo

How to prevent multiple inserts when submitting a form in PHP?

AmitDiwan

AmitDiwan

Updated on 09-Apr-2020 13:40:58

2K+ Views

PHP session can be used to prevent multiple inserts when submitting a form. PHP session sets a session variable (say $_SESSION['posttimer']) that sets the current timestamp on POST. Before processing the form in PHP, the $_SESSION['posttimer'] variable is checked for its existence and checked for a specific timestamp difference (say ... Read More

PHP Casting Variable as Object type in foreach Loop

AmitDiwan

AmitDiwan

Updated on 09-Apr-2020 11:44:45

982 Views

This depends on the IDE that is being used. For example, Netbeans and IntelliJ can enable the usage of @var in a comment −/* @var $variable ClassName */ $variable->This way, the IDE would know that the ‘$variable’ is a class of the ClassName after the hint ‘->’ is encountered.In addition, ... Read More

Sort php multidimensional array by sub-value in PHP

AmitDiwan

AmitDiwan

Updated on 09-Apr-2020 11:43:24

367 Views

The ‘usort’ function can be used to sort multidimensional arrays in PHP. It sorts an array based on a user-defined criteria −Example Live DemoOutputThis will produce the following output −2 4 63 81An array with 4 elements is declared and this array is passed to the usort function, as well as ... Read More

In PHP, how can I add an object element to an array?

AmitDiwan

AmitDiwan

Updated on 09-Apr-2020 11:41:50

3K+ Views

The code is as follows −Example$object = new stdClass(); $object->name = "My name"; $myArray[] = $object;OutputThis will produce the following output −Suppose myArray already contains ‘a’ and ‘c’, the value of “My name” will be added to it. It becomes Array {    a:0, c:1, “My name”:2 }The object is ... Read More

Advertisements