11.1. Data Types, Constants, and Variables

These functions check the status of a variable, change its type, or return a value as a particular data type.

value constant(string name)

Use constant (Listing 11.1) to fetch the value of a constant. This offers the ability to specify a constant with a variable.

Listing 11.1. constant
<?php
    function getDatabaseProperty($property)
    {
        return(constant("DATABASE_$property"));
    }

    define("DATABASE_HOST", "localhost");
    define("DATABASE_USER", "httpd");
    define("DATABASE_PASSWORD", "");
    define("DATABASE_NAME", "freetrade");

    print(getDatabaseProperty('HOST'));
?>

boolean ctype_alnum(string text)

The ctype_alnum function tests whether every character in the given string is in the set of all digits and letters, ...

Get Core PHP Programming, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.