Skip to main content

Data Types

Scalar types

Integer

Whole numbers without decimal points:

ZYMBA
$count = 42;
$negative = -10;
$zero = 0;

Float

Numbers with decimal points:

ZYMBA
$price = 19.99;
$pi = 3.14159;
$negative = -5.5;

String

Text values. Zymba supports three string delimiter styles:

ZYMBA
$single = 'Hello'; // Single quotes — no interpolation
$double = "World"; // Double quotes — supports $variable interpolation
$multiline = `Line 1
Line 2
Line 3`; // Backtick strings — multiline, supports interpolation

Backtick strings are commonly used for SQL queries and multiline text:

ZYMBA
$sql = `SELECT name, price
FROM items
WHERE status = 1
ORDER BY name`;

Boolean

ZYMBA
$isActive = true;
$isDisabled = false;

Null

Represents the absence of a value:

ZYMBA
$empty = null;

Complex types

Arrays

Ordered collections of values with optional string keys:

ZYMBA
// Indexed array
$numbers = [1, 2, 3, 4, 5];

// Associative array (object-like)
$person = [name: "John", age: 30];

// Empty array
$empty = [];

Objects

Objects created with new object() or from a class:

ZYMBA
$person = new object() {
name = "John";
age = 30;
};

Type checking

The is operator

ZYMBA
$num = 42;
$str = "hello";
$arr = [1, 2, 3];

if ($num is numeric) { } // true for int and float
if ($str is string) { } // true
if ($arr is object) { } // true — arrays are objects in Zymba

Available type checks:

CheckDescription
is numericInteger or float
is intInteger only
is floatFloat only
is stringString type
is boolBoolean type
is objectArray or object
is nullNull value
is functionFunction or closure

The typeof operator

Returns the type name as a string:

ZYMBA
echo typeof 42; // "int"
echo typeof 3.14; // "float"
echo typeof "hello"; // "string"
echo typeof [1, 2]; // "object"
echo typeof null; // "null"
echo typeof function() {}; // "function"

The exists and empty operators

Check whether a variable or key exists, or whether a value is empty:

ZYMBA
$name = "John";

if (exists $name) { } // true — variable is defined and not null

if (empty $name) { } // false — non-empty string

$blank = "";
if (empty $blank) { } // true — empty string is empty

The count operator

Returns the character count of a string or the element count of an array:

ZYMBA
$str = "hello";
echo count $str; // 5

$arr = [1, 2, 3];
echo count $arr; // 3

Type casting

Explicitly convert between types:

ZYMBA
$num = 42;
$floatNum = (float) $num; // 42.0
$strNum = (string) $num; // "42"

$price = "19.99";
$priceFloat = (float) $price; // 19.99

Available casts:

CastDescription
(int)Convert to integer (truncates decimals)
(float)Convert to float
(string)Convert to string
(bool)Convert to boolean

You can also use unary + to coerce a value to a number:

ZYMBA
$amount = +"42.50"; // 42.5 (float)

Truthiness rules

Values that are considered falsy in Zymba:

  • false
  • 0 (integer zero)
  • 0.0 (float zero)
  • "" (empty string)
  • "0" (the string "0")
  • null

Everything else is truthy, including empty arrays []:

ZYMBA
if ([]) {
echo "empty array is truthy"; // This DOES execute
}
if (0) {
// This block does NOT execute — 0 is falsy
}
if ("0") {
// This block does NOT execute — "0" is falsy
}
warning

"0" is falsy in Zymba. Check explicitly when you need to distinguish between null, "", and "0".