Programming Articles

Page 2247 of 2544

Add PHP variable inside echo statement as href link address?

AmitDiwan
AmitDiwan
Updated on 07-Apr-2020 4K+ Views

HTML in PHPecho "Link";orecho "Link";PHP in HTML

Read More

How do I sort a multidimensional array by one of the fields of the inner array in PHP?

AmitDiwan
AmitDiwan
Updated on 07-Apr-2020 292 Views

The usort function can be used to sort a multidimensional array. It sorts with the help of a user defined function. Below is a sample code demonstration − Example Output This will produce the following output − Product B - $15 Product A - $25 Product C - $35 Explanation − We have declared var_1 and var_2 with integer values. They are compared and the result is returned.

Read More

How to reset the JShell session in Java 9?

raja
raja
Updated on 07-Apr-2020 640 Views

Java 9 has introduced JShell for Java, and it allows us to evaluate code snippets such as declarations, statements, and expressions.During the JShell session, we need to reset it without closing and re-opening JShell then we can use the internal command: "/reset". By using this command, code entered during the current session has erased. It can be useful when we want to test new classes, create new variables, etc. while keeping the names previously used.In the below snippet, we have created variables x, y, and str. We can able to see all entered code snippets using the "/list" command. After that, we can apply ...

Read More

PHP string cast vs strval function, which one should I use?

AmitDiwan
AmitDiwan
Updated on 06-Apr-2020 1K+ Views

A value can be converted into a string with the help of (string) cast or the strval() function.The strval() function is a function call whereas (string) cast is an internal type casting method.Unless there is some specific dataset or use case, both of these can be used interchangeably.This is because PHP uses automatic type conversion, due to which a variable's type is determined based on the context in which it is used.The strval($var) function returns the string value of $var whereas the (string)$var explicitly converts the "type" of $var during the process of evaluation.The $var can be any scalar type ...

Read More

What are the different feedback modes in JShell in Java 9?

raja
raja
Updated on 06-Apr-2020 264 Views

When performing an operation in the JShell tool, it displays a message in return (success of the command, error, and type of a variable created as well as its value). It has been customized using the command: "/set feedback". This command displays the type of return currently configured as well as the different return modes available.jshell> /set feedback | /set feedback normal | | Available feedback modes: | concise | normal | silent | verboseThere are four feedback modes available in JShell as listed below:1) /set feedback normal: This is the default JShell feedback. When we evaluate an expression, JShell returns the corresponding result and an ...

Read More

What is the structure of JDK and JRE directory in Java 9?

raja
raja
Updated on 06-Apr-2020 2K+ Views

The directory structure of JDK and JRE are almost the same, except that JDK has two additional directories like jmods and include and also there is no JRE subdirectory in the JDK9 version. The JDK directory is the root directory for JDK software installation. This directory also includes copyright, readme, and src.zip files, which can be a source code archive file of the Java platform.JDK Directory Structure:JDK-9    - bin    - conf    - include    - jmods    - legal    - libThe JDK/bin directory contains an executable and command-line launcher that can be defined by the modules linked to an image.The JDK/conf directory contains ...

Read More

C# Program to get free space in a drive

Arjun Thakur
Arjun Thakur
Updated on 06-Apr-2020 755 Views

To get the free space in a drive, use the AvailableFreeSpace and TotalFreeSpace properties in C#.Firstly, set the name of the drive using DriveInfo −DriveInfo dInfo = new DriveInfo("D");Let’s say, you need to find the available space for D drive −Exampleusing System; using System.Linq; using System.IO; public class Demo {    public static void Main() {       DriveInfo dInfo = new DriveInfo("D");       // Get free space       Console.WriteLine(dInfo.AvailableFreeSpace);       // get total free space       Console.WriteLine(dInfo.TotalFreeSpace);    } }OutputThe following is the output showing the free space available in D drive−722243567912 722243567912

Read More

Get the drive format in C#

Chandu yadav
Chandu yadav
Updated on 06-Apr-2020 359 Views

Use the DriveFormat property to get the drive format in C#.Set the drive for which you want to display the format −DriveInfo dInfo = new DriveInfo("C");Now, use DriveFormat to get the drive format −dInfo.DriveFormatThe drive formats for a windows system can be NTFS or FAT32.Here is the complete code −Exampleusing System; using System.Linq; using System.IO; public class Demo {    public static void Main() {       DriveInfo dInfo = new DriveInfo("C");       Console.WriteLine("Drive Format = "+dInfo.DriveFormat);    } }OutputThe following is the output −Drive Format = NTFS

Read More

Convert all types of smart quotes with PHP

AmitDiwan
AmitDiwan
Updated on 06-Apr-2020 883 Views

The below lines of code can be used, wherein UTF-8 input is expected.$chr_map = array(    // Windows codepage 1252    "\xC2\x82" => "'", // U+0082⇒U+201A single low-9 quotation mark    "\xC2\x84" => '"', // U+0084⇒U+201E double low-9 quotation mark    "\xC2\x8B" => "'", // U+008B⇒U+2039 single left-pointing angle quotation mark    "\xC2\x91" => "'", // U+0091⇒U+2018 left single quotation mark    "\xC2\x92" => "'", // U+0092⇒U+2019 right single quotation mark    "\xC2\x93" => '"', // U+0093⇒U+201C left double quotation mark    "\xC2\x94" => '"', // U+0094⇒U+201D right double quotation mark    "\xC2\x9B" => "'", // U+009B⇒U+203A single right-pointing angle ...

Read More

How do you pass objects by reference in PHP 5?

AmitDiwan
AmitDiwan
Updated on 06-Apr-2020 440 Views

A PHP reference is an alias, that allows two different variables to write it to the same value. In PHP version 5, an object variable doesn't contain the object itself as its value. It holds an object identifier that allows object accessors to find the actual object. When an object is sent by an argument, returned or assigned to a different variable, these different variables are not aliases. They contain a copy of the identifier, that points to the same object. Example $my_var = new class_name; echo $my_var->get_class_name(5)->value; $my_var->test(); echo $my_var->get_class_name(5)->value; Output This will produce the following output − ...

Read More
Showing 22461–22470 of 25,433 articles
Advertisements