Generally speaking, a string is anything that you can type using the keyboard, including letters, symbols (such as &, *, and @), and digits. Sometimes a program deals with data that comes in the form of strings (text). In PHP, Java, C++, C#, Visual Basic, and Python, a string is always enclosed in double quotes like this:  “      ”.

Notice: Even though PHP and Python permits strings to be enclosed in single quotes as well, this website prefers the use of double quotes.

Each statement in the next example outputs a string.

PHP

<?php
  echo "Everything enclosed in double quotes is a";
  echo "string, even the numbers below:";
  echo "3, 4, 7";
  echo "\nYou can even mix letters, symbols and numbers like this:";
  echo "The result of 3 + 4 equals to 4";
?>

Java

public static void main(String[] args) throws java.io.IOException {
  System.out.print("Everything enclosed in double quotes is a ");
  System.out.println("string, even the numbers below:");
  System.out.println("3, 4, 7");
  System.out.print("You can even mix letters, symbols and ");
  System.out.println("numbers like this:");
  System.out.println("The result of 3 + 4 equals to 4");
}

C++

#include <iostream>
using namespace std;
int main() {
  cout << "Everything enclosed in double quotes is a ";
  cout << "string, even the numbers below:" << endl;
  cout << "3, 4, 7" << endl;
  cout << "You can even mix letters, symbols and ";
  cout << "numbers like this:" << endl;
  cout << "The result of 3 + 4 equals to 4";
  return 0;
}

C#

static void Main() {
  Console.Write("Everything enclosed in double quotes is a ");
  Console.WriteLine("string, even the numbers below:");
  Console.WriteLine("3, 4, 7");
  Console.Write("You can even mix letters, symbols and ");
  Console.WriteLine("numbers like this:");
  Console.Write("The result of 3 + 4 equals to 4");

  Console.ReadKey();
}

Visual Basic

Sub Main()
  Console.Write("Everything enclosed in double quotes is a ")
  Console.WriteLine("string, even the numbers below:")
  Console.WriteLine("3, 4, 7")
  Console.Write("You can even mix letters, symbols and ")
  Console.WriteLine("numbers like this:")
  Console.Write("The result of 3 + 4 equals to 4")

  Console.ReadKey()
End Sub

Python

print("Everything enclosed in double quotes is a ")
print("string, even the numbers below:")
print("3, 4, 7")
print("You can even mix letters, symbols and ")
print("numbers like this:")
print("The result of 3 + 4 equals to 4")

Strings are everywhere—from word processors, to web browsers, to text messaging programs. Many exercises in this website actually make extensive use of strings.

If you need more information you can visit

Notice:String functions can be used when there is a need, for example, to isolate a number of characters from a string, to remove spaces that might exist at the beginning of it, or to convert all of its characters to uppercase.

Remember! Functions (or methods) are nothing more than small subprograms that solve small problems. A subprogram can be defined as a block of statements packaged as a unit that has a name and performs a specific task.