StringA
string is any one or set of alphanumeric characters and spaces. A string may include letters, numbers, spaces, or symbols. There are several data types in PHP, and string is one of them. Here are the PHP data types again if you need to see them:
Boolean,
Integer,
Floating Point Number,
String,
Array,
Object,
Resource,
Null When we create an HTML contact form for a website we might have name, email, phone number, and message fields. When the user types their information in and press submit, all of that information in all of those fields are interepreted as strings. When our PHP parse script picks up those field variables to email them to us, they are all strings. The name is a string, the email, the phone number, and finally the message, all are strings and all will be interpreted as string data when it comes time to parse it.
String Examples:
<?php
$str1 = "Hello World!"; // Mix of Letters, Spaces, and Symbols
$str2 = "(555)555-5555"; // Mix of Numbers and Symbols
$str3 = "yourname@youremailsite.com"; // Mix of Letters and symbols
$str4 = "3"; // Number... but if it is in quotes it is seen as string data type object
$str5 = "a"; // Letter
?>
A string is simply one or any set of alphanumeric characters, spaces, and symbols.
NumberA number is anything that we would use for computational purposes or numeric representations that do not contain string type data, or any data that would make them anything but a number.
Number Examples:
<?php
$num1 = 37; // Integer
$num2 = 2.75; // Floating point numbers
$num3 = -6; // Negative values
?>