SunSed variables can hold the following data types;
- Scalar Types
- Float (floating point numbers)
- Compound Type
- Special Type
A string is any sequences of characters, it can hold letters, numbers and special characters. You may enclose the string using either double quotes or single quotes.
$full_name = "Micheal Scotch" $occupation = 'Regional General Manager'
These are whole numbers (without any decimal points - see float for decimal numbers) between -2,147,483,648 and 2,147,483,647
$age = 21 $years_driving = 3 $negative_number = -2
Floats also known as "doubles", or "real numbers" are decimal numbers.
$purchase_amount = 999.99 $customer_rating = 4.53
A boolean may be either: TRUE or FALSE
$bought_a_house = FALSE $looking_for_a_house = TRUE
In SunSed, arrays are indexed collection of key values, allowing you to hold more than one value at a time in a single variable. One of the most versatile and fundamental data types. You can add, modify, and delete (learn more at Array Library) values from an array after its creation. Array keys are unique, meaning you cannot have duplicate keys in an array.
There are two types of arrays; indexed and associative.
Indexed arrays have integer keys beginning at 0 for every value, set by the position of the value in the array, that gets automatically assigned when adding values into the indexed array.
$top_brands = ['bmw', 'toyota'] # will result to // [0 => 'bmw', 1 => 'toyota'] # accessing toyota by its key PRINT $top_brands #=> toyota
On the other hand, associate arrays have strings for their indexes which may be used to access the value.
$car_sales_by_brand = ['bmw' => 32118, 'toyota' => 89012] # accessing toyota's sales PRINT $car_sales_by_brand['toyota'] #=> 89012
Null is a special value that may only hold the value of NULL and represents a variable that has no value assigned to it.
$a = NULL
Copyright ©2013-2022 SunSed®. All rights reserved.